Exporting from a list based on a date range

Vikas Bhatia1
Kilo Contributor

Hello,

I am looking to extract cmdb data from another application using the REST api call. I want to export data based on a date range, but by not hard coding the dates. I tried by using the sysparm_query=sys_created_onONYESTERDAY+10, but it still exports all the records. Does the filter qualifier does not accept days addition or subtraction with the date values.

I am trying to resolve the issue of working withing the CSV export limit. Possible uses cases -

1.  filter by date between 1st till 15th of the month

2. filter by date between 16th till end of the month

3. filter by {current date -5}

e.g.  - to provide a list from last 5 days only. 

https://<instance>.service-now.com/cmdb_ci_computer_list.do?CSV&sysparm_default_export_fields=all&sysparm_query=sys_created_onONYESTERDAY+4&sysparm_orderby=sys_created_on

Thank you,

Vikas Bhatia

 

1 ACCEPTED SOLUTION

Mark Stanger
Giga Sage

Try the 'Relative' operator.

find_real_file.png

The encoded query for this screenshot looks like this.  You can right-click the breadcrumbs or access the URL to get the query associated with any list in the system.

https://yourinstance.service-now.com/incident_list.do?sysparm_query=sys_updated_onRELATIVEGE%40dayofweek%40ago%405

View solution in original post

5 REPLIES 5

Mark Stanger
Giga Sage

Try the 'Relative' operator.

find_real_file.png

The encoded query for this screenshot looks like this.  You can right-click the breadcrumbs or access the URL to get the query associated with any list in the system.

https://yourinstance.service-now.com/incident_list.do?sysparm_query=sys_updated_onRELATIVEGE%40dayofweek%40ago%405

Vikas Bhatia1
Kilo Contributor

Mark,

Thank you for sharing the example on the RELATIVEGE operator. It does provide me with the dataset that I am looking for. But need to understand how behind it.

I checked the documentation, but it was not that clear as to what additional conditions/functions I can use this operator with.

 

find_real_file.png

 

Would you be able to share additional information on the breakdown of your query? The example condition in the documentation is for hours. What other date/day operator can be used with RELATIVEGE?  I have other day/date based use cases that I need to build for data export. Understanding this operator would help in using it for these use cases.

e.g.

%40dayofweek =

%40ago = 

%405 = 

 

Thank you,

Vikas

Your best option for understanding specific details is to pull up a list of data in ServiceNow and use the breadcrumbs to construct your query as needed.  There's no specific documentation other than what you can find in the tool by manipulating a list and copying the query as I indicated in my original post.

Please mark my response above as correct if I've answered your question.  Thanks!

@Mark Stanger The documentation is at  https://docs.servicenow.com/ja-JP/bundle/tokyo-platform-user-interface/page/use/common-ui-elements/r...
which is the Japanese version. Good thing that chrome translates! It is odd that RELATIVEGE and RELATIVELE aren't listed in the US English version https://docs.servicenow.com/en-US/bundle/tokyo-platform-user-interface/page/use/common-ui-elements/r... 
I agree that using the UI filter will let you see what is available, but the operators are different for the various data types so unless you use a datetime field you won't see them.
Therefore the documentation is necessary and beneficial.