We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

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

faisal_dadabhoy
Giga Expert

Please look at the link: it shows you how to add days/hours and etc to server side scripts. The second link may also be helpful.



Modify a GlideDateTime Field Value - ServiceNow Wiki



GlideDateTime - ServiceNow Wiki


Slava Savitsky
Giga Sage

var gdt = new GlideDateTime();
gdt.addDays(5);


It's not work....

harikrish_v
Mega Guru

HI Kushagra,



I am guessing you used a query to fetch the date to be modified, assuming the object name is gr and field name is start_date, this is how you can use addDays method:-


var gdt = new GlideDateTime(gr.start_date);
gdt.addDays(5);


Thanks & Regards,


Hari