Incorrect dates returned by sysparm_query=sys_created_on

thedavegray
Giga Expert

Hi, 

I'm getting the wrong dates returned from the "incident" table using this url: 

 

https://company.service-now.com/api/now/table/incident?sysparm_query=sys_created_on>javascript%26col...

 

I was expecting to get only dates > 01-01-2023, however the first 1000 elements returned gives me dates from 2019. 

 

I'm doing this in Postman whilst I get the syntax correct and the final application will be in C#. 

 

e.g. 

 

thedavegray_0-1674807796851.png

 

Can anyone please advise? 

 

Thanks 

 

1 ACCEPTED SOLUTION

Basheer
Mega Sage

Hi @thedavegray 

How did you frame the query, I'm getting correct results with the below query.

https://company.service-now.com/api/now/table/incident?sysparm_query=sys_created_on%3Ejavascript%3Ag...

 

Approach to frame the query

Basheer_0-1674808854830.png

Copy the query

Basheer_1-1674808880040.png

REST API Explorer

Basheer_2-1674808926254.png

Execute

Basheer_3-1674808981559.png

This is the url for you

 

Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.

View solution in original post

5 REPLIES 5

Johns Marokky
Tera Guru

Hi @thedavegray ,

 

Can you please try the below URL and see if it works?

curl "https://company.service-now.com/api/now/table/incident?sysparm_query=sys_created_on%3E%3Djavascript%3Ags.dateGenerate('2023-01-01'%2C'00%3A00%3A00')&sysparm_limit=1000" \
--request GET \
--header "Accept:application/json" \
--user '':''


Mark helpful if it helps in solving your query.

 

Regards,

Johns

Hi @Johns Marokky 

 

I have never been able to get curl to work on our network for any url, not sure if it's blocked in some way, getting this error. 

 

curl: (35) schannel: next InitializeSecurityContext failed: Unknown error (0x80092012) - The revocation function was unable to check revocation for the certificate.

 

 

I tend to use Postman instead as this simply works with anything, including the date checking syntax you posted for curl.  😁 

 

thedavegray_0-1674811605540.png

 

I understand that %3E%3D equals  ">=" 

not  really sure what "%3Ags" means though and a Google search is not helping. 

 

That said, I wanted a range, e.g. date >= AND date < 

 

and this syntax seems to work in Postman. 👍

 

sys_created_on%3E%3Djavascript%3Ags.

dateGenerate('2023-0123'%2C'00%3A00%3A00')^

sys_created_on%3Ejavascript%3Ags.dateGenerate('2023-01-12'%2C'00%3A00%3A00')

 

Thanks 

Hi @thedavegray ,

The error message that you have mentioned is something to do with the Certificates. I would prefer to contact the network team for that issue.

 

And regarding %3Ags --> its %3A (which means ':') and gs is the function for the date generation. so in general its like javascript&colon;gs.dateGenerate('').

 

Regards,

Johns

Basheer
Mega Sage

Hi @thedavegray 

How did you frame the query, I'm getting correct results with the below query.

https://company.service-now.com/api/now/table/incident?sysparm_query=sys_created_on%3Ejavascript%3Ag...

 

Approach to frame the query

Basheer_0-1674808854830.png

Copy the query

Basheer_1-1674808880040.png

REST API Explorer

Basheer_2-1674808926254.png

Execute

Basheer_3-1674808981559.png

This is the url for you

 

Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.