- 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 02:36 AM
It's an addition, since we are in January it's 1+9 when you put
- gd.addMonthsLocalTime(parseInt(9));
And it's 1+10 = 11 when you do
- gd.addMonthsLocalTime(parseInt(10));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2017 02:43 AM
Yes but the date is one day earlier when its 9 months
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2017 04:53 AM
Try nowDateTime() instead of now()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2017 04:58 AM
Hi Mohamed,
It works when I use datetime object. However i have necessity to add months to a date object which i get from record and nt a datetime.
Is it possible to add months to a date object without messing up the dates using OOB methods?