- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 02:09 AM
Hi Team,
How to calculate seconds based on start date and end date in format (yyyy-mm-dd) in timer activity of workflow?
Please help me by providing your answer.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 02:57 AM
Hi @priyanka1028 ,
Select "Script" as an value within the attribute "Timer based on" within your Timer activity within a workflow as shown below:
Now make use of below script to get the seconds between your date attributes:
// Set 'answer' to the number of seconds this timer should wait
var start = new GlideDateTime("Pass your value here.");
var end = new GlideDateTime("Pass your value here.");
// Duration in seconds
answer = gs.dateDiff(start, end, true); // returns the number of seconds as String
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 03:00 AM
@priyanka1028 - In case if you want to pass a value from an attribute instead of hardcoding the date value in script above, then you would need to follow below steps:
1. Do a glide Record on your table and retrieve the value of date attributes.
2. Pass that into line 1 and 2 in script shared above.
3. Rest component remains same.
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 02:57 AM
Hi @priyanka1028 ,
Select "Script" as an value within the attribute "Timer based on" within your Timer activity within a workflow as shown below:
Now make use of below script to get the seconds between your date attributes:
// Set 'answer' to the number of seconds this timer should wait
var start = new GlideDateTime("Pass your value here.");
var end = new GlideDateTime("Pass your value here.");
// Duration in seconds
answer = gs.dateDiff(start, end, true); // returns the number of seconds as String
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 03:00 AM
@priyanka1028 - In case if you want to pass a value from an attribute instead of hardcoding the date value in script above, then you would need to follow below steps:
1. Do a glide Record on your table and retrieve the value of date attributes.
2. Pass that into line 1 and 2 in script shared above.
3. Rest component remains same.
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 03:04 AM
Thank you so much @shloke04
This one is going to help me a lot