- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2016 05:29 AM
Hi
I want to add months to my start date until a target date like for example
var startDate = new GlideDate();
var endDate = new GlideDate();
endDate.setValue('2016-09-09');
while(startDate<=endDate){
//do some processing
startDate.addMonth(1); //this is not an actual method just added here for verbosity
}
basically i have to generate a record for every month between the startDate and endDate
Regards
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2016 05:39 AM
Hi John,
It's not a clean solution, but you could convert the GlideDate object to a GlideDateTime and use addMonthsLocal() or addMonthsUTC(), then convert back to a GlideDate().
It's a bit messy. I'm not sure why GlideDate() doesn't have addDays(), addMonths(), and addYears() - or some variant of that. I wish it did and invite you to open an enhancement request.
Enhancement requests: Tell us how you would improve the ServiceNow product

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2016 06:27 AM
While it appears you are still able to use addMonths() to the GlideDate() class, this is deprecated and should be avoided as it does not work with the scoped API.
Reference: Scoped GlideDate API Reference - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2016 10:46 AM
Thanks Midhun for your time and effort
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2016 06:34 AM
Hi Chuck,
Thanks!! for the information.