
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2020 05:21 AM
Hi guys, is it possible to query all records created on the month before last month?
Regards, Serhii
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2020 05:55 AM
Hi,
The filter condition shared by Dhananjay should work.
Reference below
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2020 05:29 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2020 05:33 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2020 06:28 AM
Hi, thanks for your answer, no, i need to get all records created on May

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2020 06:44 AM
Hi Serhii,
Try my script you will get all records which are created on May.
Thanks,
Dhananjay.