How to do 'Greater than or equal to' comparison between two Date type of fields?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2017 10:01 PM
Hi Friends,
In a workflow I need to add a notification when End Date >= (Now Date + 7 Days) . Basically, if 1 week has passed and no action has been taken then I need to add a notification to approvals to take action. I am able to add the 7 Days to now date by using following code:
var gdt = new GlideDateTime();
gdt.addDays(-7);
var gdt2 = gdt.getDate();
gs.print(gdt2);
Now I do not know how to compare (Greater than or equal to >=) this date with End date. Any suggestions?
Thanks,
KUMAR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2017 10:26 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2017 11:01 PM
Hi ,
You can use the below script to get the days.
var gdt2 = new GlideDateTime();
var dur = GlideDateTime.subtract(gdt2, gdt1); //the difference between gdt1 and gdt2
var days = dur.getRoundedDayPart(); // this will give the rounded day value
gs.print(days);
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2020 01:05 PM
This helped tons and worked great. Thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2017 12:05 AM
var gdt= new GlideDate();
gdt.addDays(-7);
gs.print(gdt);
var gdt2 = new GlideDate();
gs.print(gdt2);
//Simple Compare
if(gdt<=gdt2){
gs.print("tt");
}
//Using funcation
gs.print(gdt.compareTo(gdt2));
// Equals :0
// Earlier than :1
// Later than :-1