addDaysLocalTime() shows undefined
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2018 11:31 PM
Why does the below code returns undefined? I tried this in Background- Scripts and Business Rule with same result.
date();
function date()
{
var gd = new GlideDateTime("2018-04-18 00:31:57");
gs.print(gd.addDaysLocalTime(28));
}
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2018 11:44 PM
Hi Aditya,
After var gd = new GlideDateTime("2018-04-18 00:31:57");
Add gd.addDaysLocalTime(28);
And then gs.print(gd.getLocalDate());
// Output: 2018-04-18
Mark If Helpful
Thank You
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2018 11:45 PM
Hi
I think you are printing wrong value, could you please check as shown below:
date();
function date()
{
var gd = new GlideDateTime("2018-04-18 00:31:57");
gd.addDaysLocalTime(28);
gs.print(gd);
}
Please mark it correct, if it resolves your problem.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2025 03:49 AM
I am having the same issue. Please could someone help?
Output:
*** Script: 2 days added is: 2025-07-14 00:00:00The function to add 2 days, seem to not work.
*** Script: 2025-07-14 00:00:00
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2025 04:01 AM
*** Script: 2025-07-14 00:00:00
*** Script: 2 days added is: 2025-07-14 00:00:00
*** Script: 2025-07-14 00:00:00
The function to add 2 days, seem to not work.