Data time gs.beginningOfLast2Years() vs gs.beginningOfLastYear()

vkachineni
Kilo Sage
Kilo Sage

This is on Kingston

glide-kingston-10-17-2017__patch12-11-28-2018_12-04-2018_0932

 When I run the following script as a background script I get the same value for the two function calls

gs.info("2 years: " + gs.beginningOfLast2Years() + "   One year: " + gs.beginningOfLastYear());

*** Script: 2 years: 2018-01-01 08:00:00   One year: 2018-01-01 08:00:00

How can  gs.beginningOfLast2Years() and gs.beginningOfLastYear() return the same value?

 

 

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022
1 ACCEPTED SOLUTION

Alexey7
Mega Sage

Hi, 

I don't see gs.beginningOfLast2Years() anywhere in ServiceNow docs. So I have only suggestion for you to figure out the beginning of the year/years based on gs.beginningOfLastYear() + use GlideDateTime method .addYearsLocalTime(-1).

Hope it helps.

View solution in original post

2 REPLIES 2

Alexey7
Mega Sage

Hi, 

I don't see gs.beginningOfLast2Years() anywhere in ServiceNow docs. So I have only suggestion for you to figure out the beginning of the year/years based on gs.beginningOfLastYear() + use GlideDateTime method .addYearsLocalTime(-1).

Hope it helps.

Thanks Alexey,

I was using the filter on a list to get a list of lincidents created before last 2 years

When I copied the query, it showed the following filter

sys_created_on<javascript:gs.beginningOfLast2Years()

 

This led me to believe there is a gs.beginningOfLast2Years().

 

Thanks,

Vin

 

 

 

 

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022