Is it possible to get all records created on the month before last month?

Serhii5
Mega Guru

Hi guys, is it possible to query all records created on the month before last month? 

Regards, Serhii

1 ACCEPTED SOLUTION

Hi,

The filter condition shared by Dhananjay should work.

Reference below

find_real_file.png

Script also gives 16 count:

var gr=new GlideRecord('incident');

gr.addEncodedQuery('sys_created_on<javascript:gs.beginningOfLastMonth()^sys_created_on>javascript:gs.beginningOfLast60Days()');

gr.query();

gs.info(gr.getRowCount());

Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

9 REPLIES 9

Kunal Varkhede
Tera Guru

Hi,

 

Yes it is possible.

Try like below in addquery method of GlideRecord API

Created on LastMonth

OR Try with below encoded query

Encoded Query-sys_created_onONLast month@javascript:gs.beginningOfLastMonth()@javascript:gs.endOfLastMonth()

 

Thanks,

Kunal

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

so are you saying current month is July so you want records created in May i.e. month before last month

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi, thanks for your answer, no, i need to get all records created on May

Hi Serhii,

Try my script you will get all records which are created on May.

Thanks,

Dhananjay.