From: | rob stone <floriparob(at)gmail(dot)com> |
---|---|
To: | Paul McGarry <paul(at)paulmcgarry(dot)com>, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
Cc: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: How to get timezone offset in timestamp with time zone AT TIME ZONE output. |
Date: | 2019-09-25 02:56:38 |
Message-ID: | 85cd91320ad71bd44d8d82aed52b29c2b08888ab.camel@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, 2019-09-25 at 10:12 +1000, Paul McGarry wrote:
>
> On Wed, Sep 25, 2019 at 5:44 AM Adrian Klaver <
> adrian(dot)klaver(at)aklaver(dot)com> wrote:
> >
> Andrew's function seems plausible and I need to find some time to
> test it, but I am slightly surprised there isn't a native way to get
> the output, as it seems like something that would be fairly useful
> when dealing with dates.
>
> Perhaps another avenue would be some sort of getOffset function, eg
>
> getOffset('2019-09-25 02:00:00+00','Australia/Sydney')
> that would return +11 (or just 11).
>
> Presumably PostgreSQL must have some internal functionality like that
> because it can do that math on the datetimes, but it doesn't seem to
> be exposed to users.
>
> Thanks all for your input.
>
> Paul
>
You can EXTRACT timezone, timezone_hour and timezone_minute from a
timestamp. Using 'timezone' returns a value representing seconds from
UTC.
Maybe you could just concatenate the date/time with the extracted
offset in your select statement.
HTH,
Robert
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Gierth | 2019-09-25 03:01:39 | Re: How to get timezone offset in timestamp with time zone AT TIME ZONE output. |
Previous Message | Andrew Gierth | 2019-09-25 02:46:25 | Re: How to get timezone offset in timestamp with time zone AT TIME ZONE output. |