add and remove days question

ServiceNow Use6
Tera Guru

Hi,

I'm not good with dates and times, so I'm practicing now. Kindly help.

 

var gdt = new GlideDateTime("2025-07-03 08:03:35");
var adding = gdt.addDays(10).toString(); //add 10 days to current date time
var removing = gdt.addDays(-1); //remove 1 days from current date time
gs.addInfoMessage(gdt);
gs.addInfoMessage(adding);
gs.addInfoMessage(removing);

 

1.jpg

 

Regards

Suman P.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@ServiceNow Use6 

addDays() doesn't return anything.

You can always go to Docs for what that method does

That's the best way to learn and explore.

GlideDateTime - Global 

var gdt = new GlideDateTime("2025-07-03 08:03:35");
gdt.addDays(10); //add 10 days to current date time

gs.addInfoMessage('adding' + gdt.getValue());

var nowTime = new GlideDateTime();
nowTime.addDays(-1); //remove 1 days from current date time

gs.addInfoMessage('removing' + nowTime.getValue());

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

5 REPLIES 5

@ServiceNow Use6 

Please note that multiple answers can be accepted. It’s a helpful practice that supports contributors and benefits future readers.

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */