Current date/time to compare with end date/time minus 3 days
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2024 10:26 PM
Hi Folks,
I have below script in wait for condition activity of wf, where i need to check if currentDateTime == endDateTime - 3 days
Suppose "current.variables.end" is 2024-08-30 10:30:00
current date/time is 2024-08-26 10:30:00
result: This script should trigger next activity when current datetime reaches 2024-08-27 10:30:00 , that is 3 days minus 2024-08-30 10:30:00, BUT ITS NOT WORKING, Please suggest the correction.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2024 12:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2024 12:55 AM - edited 08-26-2024 12:57 AM
Hi @Ravi Gaurav Please check this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2024 01:00 AM
That's strange..
I did more changes and hit and trail.. use the below
function ifScript() {
var currentDateTime = new GlideDateTime();
var endDateTime = new GlideDateTime(current.variables.end);
endDateTime.addDaysUTC(-3);
gs.log('Current DateTime: ' + currentDateTime.getDisplayValue());
gs.log('End DateTime minus 3 days: ' + endDateTime.getDisplayValue());
var tolerance = 60 * 1000;
var timeDiff = Math.abs(currentDateTime.getNumericValue() - endDateTime.getNumericValue());
if (timeDiff <= tolerance) {
return true;
}
return false;
}