Compare a Date Field with the Current Servicenow Date.

crhistopherjuar
Kilo Expert

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.

find_real_file.png

I think my code is not working because the order of the values.

Do you have any Idea why my code is not working?

6 REPLIES 6

Hi Goran,



Exactly thats why I am not using glideDateTime.
Do you have another method that I can use to compare them?


timwilliams
Mega Contributor

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);