Question about REST API query using sys_created_on

Bajeet
Kilo Contributor

I have this record:

{ "u_implemented": "false", "number": "INNO003008", "sys_id": "36745829db0223004c53d426ca9619b6", "u_description": "Sune Boye Riis was on a bike ride with his youngest son, enjoying the sun slanting over the fields and woodlands near their home north of Copenhagen, when it suddenly occurred to him that something about the experience was amiss. Specifically, something was missing.\r\n\r\nIt was summer. He was out in the country, moving fast. But strangely, he wasn't eating any bugs.", "u_idea_type": "process improvement", "sys_updated_by": "admin", "sys_created_on": "2018-11-27 22:02:32", "sys_mod_count": "1", "sys_updated_on": "2018-11-27 22:03:05", "sys_tags": "", "u_string_2": "The Insect Apocalypse Is Here What does it mean for the rest of life on Earth?", "sys_created_by": "admin" }

When I send this as the sysparm_query, it doesn't return the above record:

`sys_updated_on>javascript:gs.dateGenerate('2018-11-27','22:02:00')^ORsys_created_on>javascript:gs.dateGenerate('2018-11-27','22:02:00')^ORDERBYDESCsys_created_on`

Is there a problem with my query? The record has a `sys_created_on` value of "2018-11-27 22:02:32" and a `sys_updated_on` value of "2018-11-27 22:03:05". Shouldn't that be returned by the above query?

1 ACCEPTED SOLUTION

Best option will be is to set UTC time zone on service account (user record) that you are going to use for REST calls.

View solution in original post

11 REPLIES 11

Go to the record you are not getting in response, right click on header and do show XML and make sure sys_created_on and sys_updated_on has same value you are passing in your query. All SN data is stored in UTC zone and based on user zone it will display time so doing show XML will show you correct date/time that you can pass in.

Bajeet
Kilo Contributor

Cool, I didn't know about that feature. Here is the XML I get. Looks like the dates are after the date I'm sending in the query.

find_real_file.png

That's the issue than. You need to pass in value in UTC zone.

Bajeet
Kilo Contributor

Ah, that's good to know. Right now, I'm sending

sys_updated_on>javascript:gs.dateGenerate('2018-11-27','22:02:00')

. Is there some way I'm supposed to specify UTC in that date/time?

The sys_created_on of that post is "2018-11-27 22:02:32".

Best option will be is to set UTC time zone on service account (user record) that you are going to use for REST calls.