- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2017 02:24 AM
Does this function calculates result based upon number of days/ just plays with the months part ? I see ambiguity as below..
gs.print(gs.now());
var gd = new GlideDateTime();
gd.setValue(gs.now());
gd.addMonthsLocalTime(parseInt(9));
gs.print(gd.getValue());
Output:
*** Script: 2017-01-06
*** Script: 2017-10-05 23:00:00
Whereas replacing number of months with 10 produces below result.
*** Script: 2017-01-06
*** Script: 2017-11-06 00:00:00
Why the one hour ambiguity when its 9 months?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2017 05:44 AM
Try the following:
var gd = new GlideDateTime();
gd.addMonthsUTC(parseInt(9));
gs.print(gd.getValue());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2017 05:44 AM
Try the following:
var gd = new GlideDateTime();
gd.addMonthsUTC(parseInt(9));
gs.print(gd.getValue());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2017 05:29 AM
Try using gs.nowDateTime() as follows->
var gd = new GlideDateTime(gs.nowDateTime());
gd.addMonthsLocalTime(parseInt(9));
gs.print(gd.getValue());
You get the correct value then.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2017 05:59 AM
To add months to a date object,
- converted it to a date time object.
- Added months using addMonthsUTC
- Set the value to date object. ( i hope date time to date conversion happens internally while such assignment)