How to check the date is within 3 months of the current date?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2015 11:11 PM
I need to check the date is within 3 months of the current date. I checked it by 90 days but the requirement is for 3 months. I need to check date within 3 months. means its may be either 90 days or 92 days. kindly help me into this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2015 11:52 PM
Hi Anshul,
I think you can use monthsAgo(3) method (Gets a date and time for a certain number of months ago)
GlideSystem Date and Time Functions - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2015 12:09 AM
current.sys_created_on>gs.monthsAgoStart(3)
Or, as previously mentioned:
current.sys_created_on>gs.monthsAgo(3)
Encoded query:
sys_created_on>javascript:gs.monthsAgoStart(3)
sys_created_on>javascript:gs.monthsAgo(3)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2015 02:19 AM
Hi,
this method doesn't provide exact 3 months. it provides the first date of month.
For Example if I select 5-Oct-2015 then by gs.monthsAgoStart I got the value 1-Oct-2015. Not 5-Oct-2015.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2015 03:04 AM
how about addMonthsLocalTime(); method?
var gDate = new GlideDate();
gDate.setValue('2015-05-01');
gDate.addMonthsLocalTime(-3); // I got 2015-02-01