How do I add timezones to my Datetime values?

Aarthi
Aarthi
  • Updated

SQL logs timestamps in two formats: timestamp and timestamptz. timestamp refers to timestamp without timezone, whereas timestamptz refers to timestamp with timezone. Benchling warehouse stores datetime data in UTC timezone.

Therefore, if you’d like to show timezones in your query, cast your timestamp value to timestamptz before converting to your desired timezone as shown below:

SELECT
timezone('US/Pacific', created_at.datetime::timestamptz) as "Created Time"
FROM org.registry_entity$raw
Additional resource

List of available timezones: https://www.postgresql.org/docs/7.2/timezones.html
More details on using timezones: https://phili.pe/posts/timestamps-and-time-zones-in-postgresql/

Was this article helpful?

Have more questions? Submit a request