query records created before last 6 months

kushal_dangare
Tera Expert

Hi,

how can I get records from incident table created before Last 6 months?

I tried javascript:gs.daysAgo(180) but the count is not exactly matching.

2 REPLIES 2

Abhishek77
ServiceNow Employee
ServiceNow Employee

Hi

Use this script to find records which were created in last six months from today

var gr= new GlideRecord('incident');
gr.addEncodedQuery('sys_created_on>=javascript:gs.beginningOfLast6Months()');
gr.query();
while(gr.next()){
var num=gr.number;
gs.log(num);
}

 

Use this query if you want the records created before last six months

sys_created_on<=javascript:gs.beginningOfLast6Months()

Mark the answer as Correct/Helpful based on its impact.

Thanks

Can this be modified to select records created on the last 12 months?