Glide DateTime
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2024 09:38 AM
How can I add days to my existing date time field
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2024 09:45 AM - edited ‎04-22-2024 09:45 AM
I think there's a "addDaysLocalTime()" function oob.
// Input date as GlideDateTime object
var inputDate = new GlideDateTime(); // Use current date and time as input
var daysToAdd = 7; // Number of days to add
// Clone the input date to avoid modifying it directly
var newDate = new GlideDateTime(inputDate);
// Add the specified number of days to the new date
newDate.addDaysLocalTime(daysToAdd); // Use addDaysUTC() for UTC time
// Output the new date
gs.info("Input Date: " + inputDate);
gs.info("Number of Days to Add: " + daysToAdd);
gs.info("New Date: " + newDate);