How to check the date is within 3 months of the current date?

lajklkj
Kilo Contributor

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.

9 REPLIES 9

epam
Kilo Guru

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


Dan_Berglin
Giga Expert

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)


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.


how about addMonthsLocalTime(); method?



var gDate = new GlideDate();


gDate.setValue('2015-05-01');


gDate.addMonthsLocalTime(-3); // I got 2015-02-01