How to do 'Greater than or equal to' comparison between two Date type of fields?

ashwanikumar
Tera Expert

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

7 REPLIES 7

Kalaiarasan Pus
Giga Sage

Have you tried using the normal > and < operators with the dates? That should work as well.


divya mishra
Tera Guru

Hey Ashwani,



You can use ->


end date >= gs.nowDate() + gs.daysAgo(-7)



post me your feedback


Please Hit ✅Correct, ��Helpful, or ��Like depending on the impact of the response


Have a lovely day ahead




Regards,


Divya Mishra


Hey Ashwani,



There is one mistake in your code:


var gdt = new GlideDateTime();


gdt.addDays(7); // here you need to add positive days


var gdt2 = gdt.getDate();


gs.print(gdt2);



now you can use your operators:)



post me your feedback


Please Hit ✅Correct, ��Helpful, or ��Like depending on the impact of the response


Have a lovely day ahead




Regards,


Divya Mishra