How do use gs.monthsAgoStart?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2016 01:50 PM
Hello,
I am having trouble understanding how to use the gs.monthsAgoStart()
I am just trying to find the date 3 months from today.
var newTime = new GlideDateTime();
var startTime = gs.monthsAgoStart(3);
Not sure where I am supposed to put my newTime variable..
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2016 01:57 PM
Here you go
var newTime = new GlideDateTime();
newTime.addMonthsLocalTime(3);
var startTime= newTime.getValue();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2016 02:01 PM
monthsAgoStart gives you the first day of the month 3 months ago.
Example:
var date = gs.monthsAgoStart(3);
gs.print(date);
Gives a result of August 1st, 2016 if run during November 2016
You should use monthsAgo.
Example:
var date = gs.monthsAgo(3);
gs.print(date);
Gives a result of August 10th 2016 if run today November 10th 2016
Note: The result is in GMT and includes the time as well
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2016 06:30 AM
For some reason, my date is not printing when I try to do this:
var newTime = gs.monthsAgoStart(3); | |
var endTime = gs.monthsAgoEnd(3); |
tasks.addQuery('u_aom_estimated_remaining_hour','>=', startTime);
tasks.addQuery('u_aom_estimated_remaining_hour','<=', endTime);
Not sure what I am doing wrong. I see valid data from the queried table that should be pulled.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2017 11:17 AM
You might be using the wrong variable change startTime to newTime