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.

Need to know how does addDays() work in script include ? I have already fetched today's date via script include,need to alter this date by 5 days.

kforkush
Kilo Contributor

Need to know how does   addDays() work in script include ? I have already fetched today's date via script include, need to alter this date by 5 days.

5 REPLIES 5

Michael H
Giga Guru

Hi kforkush,

I had similar issues but was able to get it working by using "addDaysUTC()" instead of "addDays()".

Please see example below:

var gdt = new GlideDateTime("2011-08-31 08:00:00");
gs.info('DEBUG (1): ' + gdt); //Debug
gdt.addDaysUTC(10);
gs.info('DEBUG (2): ' + gdt); //Debug	

You can replace the above date string with your retrieved date for today.

 

Side note: In my case I ended up using ".getDisplayValue();" for it to work in the JSON response of the script include.

 

Hope that helps,

- Mike