- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2024 04:16 PM - edited 09-21-2024 04:18 PM
Hi
Can one help to get no of incidents created yesterday with out using encoded query
below is the code I am trying, its not woking whereas it is working with encoded query
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2024 04:43 PM - edited 09-21-2024 04:49 PM
The opened_at field is a date/time, and you are comparing it to date only field, so there aren't any records that are equal. An approach more like this will work
var gr =new GlideAggregate('incident');
gr.addQuery('opened_at', '>=', gs.daysAgoStart(1));
gr.addQuery('opened_at', '<=', gs.daysAgoEnd(1));
gr.addAggregate('COUNT');
gr.query();
if(gr.next()){
gs.print("no of incidents created yesterday:"+ gr.getAggregate('COUNT'));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2024 04:43 PM - edited 09-21-2024 04:49 PM
The opened_at field is a date/time, and you are comparing it to date only field, so there aren't any records that are equal. An approach more like this will work
var gr =new GlideAggregate('incident');
gr.addQuery('opened_at', '>=', gs.daysAgoStart(1));
gr.addQuery('opened_at', '<=', gs.daysAgoEnd(1));
gr.addAggregate('COUNT');
gr.query();
if(gr.next()){
gs.print("no of incidents created yesterday:"+ gr.getAggregate('COUNT'));
}