Compare a Date Field with the Current Servicenow Date.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2017 02:04 PM
Hi Experts,
I am trying to Compare a Date Field with the Current Servicenow Date.
The Date field is called "u_end_date" and it is just a Date Field, not a Date Time Field.
So right now I am just trying to compare the Date field with the Current Servicenow Date to send a message, if these dates are the same just send an info message that the dates are the same. I did a business rule but is not working.
This is the business rule code:
var now = gs.now();
var end = current.u_end_date;
if (now == end){
gs.addInfoMessage( now + "=" + end);
}
I did a test before, with out the if condition to see the values of both and I see that the order of the values are different.
I think my code is not working because the order of the values.
Do you have any Idea why my code is not working?
- Labels:
-
Scripting and Coding
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2017 07:10 AM
Hi Goran,
Exactly thats why I am not using glideDateTime.
Do you have another method that I can use to compare them?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2019 01:10 PM
var date1 = current.sys_created_on;
var date2 = gs.nowDateTime();
var diffSeconds = gs.dateDiff(date1.getDisplayValue(), date2.getDisplayValue(), true);
var convertsecondstodays = parseInt(diffSeconds/1440/60);