Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Comparing Date and Date/Time fields

Red HK
Tera Contributor

I am trying to write a script using a generic script, however my "Valid To" date is in Date format, not in Date/Time format.

The difference between the Valid to - Date field vs Score - Date/Time field is causing issues with the script

var diff=function(x,y){return y.dateNumericValue() - x.dateNumericValue();};
var days=function(x,y){return diff(x,y)/(24*60*60*1000);};
days(current.Valid_to, score_end);

1 REPLY 1

Allen Andreas
Tera Patron

Hello,

You can always instantiate a new GlideDateTime object and then set the value with just the date from the field that is date only, then...both objects will be in the same format and you can go from there.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!