Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2025 02:31 AM
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);
Regards
Suman P.
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2025 02:38 AM
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.
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2025 08:02 AM
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! */
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */