Skip to content

Instantly share code, notes, and snippets.

@will123195
Last active March 13, 2020 11:57
Show Gist options
  • Save will123195/a62706c936cdff790c65341d9610b4bb to your computer and use it in GitHub Desktop.
Save will123195/a62706c936cdff790c65341d9610b4bb to your computer and use it in GitHub Desktop.
Postgres: How to return timestamp with local timezone
select
id,
"utcStartTime",
"utcOffset",
"localStartTime" || "utcOffset" as "startTime"
from (
select
id,
"startTime" as "utcStartTime",
("startTime" at time zone 'UTC' at time zone "timezoneOffset")::timestamp as "localStartTime",
"timezoneOffset" as "utcOffset"
from "myTable"
where id in (
'cb354b18-2c07-49a8-85b6-e05b9a9e1993',
'00000004-b14f-4012-b115-43a49db5b76f',
'ffffffd8-3c29-43d0-b1d9-631760ed055d'
)
) as tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment