The CreatorCon Call for Content is officially open! Get started here.

How to query Table with UTC timestamp?

Shaan2
Tera Contributor

How to query using Table API but with UTC timestamp? 

I'm making a request to the Table API like so:

https://<domain-name>.service-now.com/api/now/table/kb_use?sys_created_on>javascript:gs.dateGenerate('2022-05-16','15:56:00')&sysparm_limit=100

But the time param in the query is being considered in the local time zone, what else should I pass so that it gets considered as UTC time? (I don't want to convert to local time)

9 REPLIES 9

Hello Shaan,

If this has answered the question, kindly mark my comment as a correct answer so that the question is moved to the solved list.

Shaan2
Tera Contributor

Hi!
The sysparm_display_value changes the display value of the records that are returned. What I actually need is a way to provide the time that I'm passing as a query parameter to be in UTC. 

so for the sysparm_query parameter, the time I'm passing is being considered to be in the local time zone of the instance, but I want the query parameter to be considered in the UTC time zone.

Hi Shaan2,

 

The simplest solution would be to change the API user to have the UTC (GMT) timezone. I cannot see anything in GlideRecord (query) or Table API that lets you pass in anything other than user's current timezone.

you can use javascript&colon;GlideDateTime that won't do any conversion

BaibhabK
Tera Contributor

Facing the same issue here. Were you able to find a solution for your problem? In my case, I want to query based on the "sys_updated_on" field. 
sys_updated_on>=javascript&colon;gs.dateGenerate('2025-1-23', '5:30:27')

But it returns no results. This time value is in my local timezone (EST), while my sys_user/instance timezone is PST (EST - 3 hours). If I put the time value as '2:30:27', it works (my local time - 3 hours). So it seems this time needs to be sent to dateGenerate in the sys_user timezone.
Would be so much more convenient to be able to pass the time as GMT, since it seems the API stores the sys_updated_on value in GMT anyway. Did you find a solution/workaround?