- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2023 07:17 AM
Hi all,
Can I please get some starter advice on using the query parameter sysparm_query on the Incident table.
Is it possible to get a date range based upon the sys_created_on field? So for example I would like to get just elements that match sys_created_on>=2022-01-21 AND <2022-01-22, I tried this but it does not work, it returns
elements for 23rd, 24th etc,
sys_created_on%3E%3D2022-01-21&sys_created_on%3C2022-01-22
On the understanding that %3E%3D is >= and %3C is < (less than).
Is it not possible to use multiple parameters with sys_created_on?
Screenshot of query running in Postman with values greater that
Thanks
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2023 07:25 AM - edited 01-24-2023 07:25 AM
It should be like this
sys_created_on>javascript:gs.dateGenerate('2022-01-22','00:00:00')^sys_created_on<javascript:gs.dateGenerate('2022-01-23','23:59:59')
Full link should be like this
Please mark correct if my response has solved your query.
Cheers,
Mohammed Basheer Ahmed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2023 12:18 AM
Hi @Basheer
Even just using a greater than date with sysparm_query does not seem to work for me. For example, this url which should filter dates only for this year :
However a distinct list of the first 1000 elements gives these sys_created_on dates:
- 2019-06-12
2019-06-13
2019-06-14
2019-06-15
2019-06-16
2019-06-17
I might post this as a new question as I already marked this one as answered.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2023 07:39 AM
The easiest way to get the query you need is to go to the incident list, filter the list the way you want and then right click on the last part of the filter and select copy query. Then just past that into the box you have for sysparm_query. It should work just fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2023 11:58 PM
Hi @DrewW & @Hayo Lubbers
I have filtered the incident list as you both mention on created > 30 days and created < today, or at least that's what I think it now says. This is what the sysparm_query param looks like now
sysparm_query%3Dsys_created_on%253Ejavascript%3Ags.beginningOfLast30Days()%255Esys_created_on%253Cjavascript%3Ags.beginningOfToday()%26sysparm_first_row%3D1%26sysparm_view%3D
I'm not sure where the sysparm query now ends if I'm honest as my "&" query param delimiters have now gone. Seems like sysparm_first_row and sysparm_view are part of the view formatting for the incident list, not really sure they would work as part of the REST call.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2023 12:38 AM
Hi @thedavegray,
Even without the sysparm_first_row and sysparm_view your url would work. Those are present in the url to decide the first record of table and data view from which they need to be taken.
These will be useful when we are trying to send the data in chunks then you can set the offset(5000), firstrow(1st row 0 for 1st call, 1st row 5000 for next call and so on)
Please mark correct if my response has solved your query.
Cheers,
Mohammed Basheer Ahmed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2023 02:17 AM - edited 01-26-2023 02:17 AM
Hi @Basheer
Ah, I was going to ask about paging in a separate forum post.
So basically it would be along the lines of.
sysparm_first_row=1&sysparm_limit=1000
then
sysparm_first_row=1001&sysparm_limit=1000
etc?
I was going to run my consumer every day and collect elements that are perhaps under two days for insert or update into SQL.
Thanks