How to add 14 days from the day when it was created

Santhosh23
Tera Expert

How to add 14 days to one of the date field from when it was created in scoped app.

 

var gd = new GlideDateTime();

gd.addDaysLocalTime(14);

gd.setDateNumericValue(gd.getNumericValue());

 

Its adding 14 days but when the record created after 8 PM time . its adding 15 days.

 

can someone please help me in adding exactly 14 days from the date when it is created

6 REPLIES 6

Saurabh Gupta
Kilo Patron
Kilo Patron

Hi,
Please try below

var gd = new GlideDateTime();

gd.addDays(14);

 

 


Thanks and Regards,

Saurabh Gupta

I tried but addDays() wont support in scoped app.

Hi,
I think addDaysUTC() should work.

 

 


Thanks and Regards,

Saurabh Gupta

Ankur Bawiskar
Tera Patron
Tera Patron

@Santhosh23 

please use addDaysUTC()

in which field you are setting the value?

var gd = new GlideDateTime();
gd.addDaysUTC(14);
gd.setDateNumericValue(gd.getNumericValue());

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader