Compare two dates field lesser than or equal to
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2024 11:49 AM
Hello,
I have two datetime fields, one is a read only field which populates 90th day from today and the other is inputted from the end user. I need to check if the inputted value is less than or equal to the read only field in the workflow. I'm usinfg the below script in the workflow and getting an error. Please help me with this. TIA.
answer = ifScript();
function ifScript(){
var now = new GlideDateTime(current.default_end_date);
var end = new GlideDateTime(current.risk_acceptance_ending_date);
gs.log('Default End date is' + now);
gs.log('Selected End date is' + end);
if (now.getNumericValue() > end.getNumericValue() )
{
gs.log("Inside loop");
return 'yes';
}
gs.log("Outside loop");
return 'no';
}
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2024 05:25 PM
Hi, I would look at using dateDiff() method, the documented example looks to be aligned with your requirement.
GlideSystem | ServiceNow Developers