- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2016 05:13 AM
how i get the count of incidents which are created last month not in last 30 days with out specifying any date using background script, without using any report types I dont want want to specify any date any month. suppose i am checking using background script in december the count will display the no. of incidents for the month of november .... how can i do it??
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2016 06:12 AM
Please try
var ga = new GlideAggregate('incident');
ga.addQuery('opened_atONLast month@javascript:gs.beginningOfLastMonth()@javascript:gs.endOfLastMonth()');
ga.addAggregate('COUNT');
ga.query();
var incidents_opened = ga.next() ? ga.getAggregate('COUNT') : 0;
gs.info(incidents_opened);
Please feel free to connect, follow, mark helpful / answer, like, endorse.
John Chun, PhD PMP ![]() | ![]() |

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2016 05:28 AM
Start by building the same query using the list filter and then copy the query to manipulate it the way you want.
See this video for help: Video: Scripting Complex Queries Quickly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2021 05:18 AM
Hi
How do I get the count of incidents which were updated before 11 months ?
I guess list filter option would not be helpful in this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2024 03:12 AM
How to check the count of incidents when we are selecting it from list in servicenow?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2016 05:28 AM
Suprakash,
You should be able to build a GlideRecord query that compares dates to today's date using these methods:
GlideSystem Date and Time Functions