- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2022 08:33 PM
I've a requirement where I'll give input some Date and I want to get Day and Month of that date. Need script help for that
Example:
input: 2022-08-17
Output:
Day: 17
Month: 08
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2022 05:17 AM
Hello
You can follow the below steps.
Go to Flow designer click on create new Action.
1. Create action input step:
2. click on + icon and slect Script to create a Script action. Create Input Variables for script step to provide the input to the script. Click on Data pill picker to add the value to this variable from Inputs--> Date time variable. (ie. variable from step 1)
In script specify the below script:
(function execute(inputs, outputs) {
var dateGDT = new GlideDate();
dateGDT.setValue(inputs.date_value + "");
outputs.month_value = dateGDT.getMonthNoTZ();
outputs.date_value = dateGDT.getDayOfMonthNoTZ();
})(inputs, outputs);
Create Output vairable for script step as show below:
3. Create Outputs as shown below. You need to first create Output variables. Click on Exist Edit mode button. Then assign the value to those variable by clicking on Data pill picker icon and using the variable created as output variables in step 2.
Click on Save. Then to test the action click on Test button. Provide the date value and then check the values in flow execution:
If my answer helped you in any way then please do mark it as helpful. If it answered your question then please mark it correct and helpful. This will help others with similar issue to find the correct answer.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2022 09:24 PM
Hello Dee,
You can use following code for getting Day and the Month. Try it in the background script.
gs.info(new GlideDateTime("2022-08-17").getMonthLocalTime());
gs.info(new GlideDateTime("2022-08-17").getDayOfMonthLocalTime());
OUTPUT:
8
17
For more information, please refer https://developer.servicenow.com/dev.do#!/reference/api/sandiego/server/c_APIRef
Please mark the answer correct if it helps. 🙂
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2022 09:46 PM
I want to write script in flow designer action not a normal java script. How to pass inputs and outputs in flow designer action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2022 09:58 PM
u_birthdy field type is "date"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2022 05:17 AM
Hello
You can follow the below steps.
Go to Flow designer click on create new Action.
1. Create action input step:
2. click on + icon and slect Script to create a Script action. Create Input Variables for script step to provide the input to the script. Click on Data pill picker to add the value to this variable from Inputs--> Date time variable. (ie. variable from step 1)
In script specify the below script:
(function execute(inputs, outputs) {
var dateGDT = new GlideDate();
dateGDT.setValue(inputs.date_value + "");
outputs.month_value = dateGDT.getMonthNoTZ();
outputs.date_value = dateGDT.getDayOfMonthNoTZ();
})(inputs, outputs);
Create Output vairable for script step as show below:
3. Create Outputs as shown below. You need to first create Output variables. Click on Exist Edit mode button. Then assign the value to those variable by clicking on Data pill picker icon and using the variable created as output variables in step 2.
Click on Save. Then to test the action click on Test button. Provide the date value and then check the values in flow execution:
If my answer helped you in any way then please do mark it as helpful. If it answered your question then please mark it correct and helpful. This will help others with similar issue to find the correct answer.
Thanks