Getting specific records by relative date

KB15
Giga Guru

How would I script to get a count of records relative to the current date? This wouldn't be a range. It would be specific to a specified number of days like 3 days ago, 2 days ago, etc. (eg Get the number of incidents created 3 days ago relative to the current day)

I tried to see if I could get a filter going by using "Created relative on 3 days ago" but I get zero results. I can easily get a range of records by using on before or after but I can't seem to get records when specifying a specific number of days.

Ultimately, I need to get the difference between incidents created vs resolved per day over 3 days. It wouldn't be a total over 3 days.

1 ACCEPTED SOLUTION

KB15
Giga Guru

It seems like this is a bug that ServiceNow won't fix. The ability to choose a day relative to the current day is not possible per PRB1017188.

View solution in original post

14 REPLIES 14

if you bring up incidents and filter: first column is created, second choose "relative", on or after, 3, days, ago

that is the query above.

 

to get the encoded query string, run your query in the list, right click on the filter and select copy query

This is the problem with the list view. It's the same query but I get zero results. A script yields a number. A bug perhaps?

 

find_real_file.png

don't use "ON"

use "ON OR AFTER"

you have none create exactly 3 days ago

create a record and you will get at least one

Wouldn't that give me more results I would need? I would need to get records specifically created in that 12am-11:59pm window 3 days ago.