pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: rob stone <floriparob@gmail.com>
To: Paul McGarry <paul@paulmcgarry.com>
To: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: How to get timezone offset in timestamp with time zone AT TIME ZONE output.
Date: Wed, 25 Sep 2019 12:56:38 +1000
Message-ID: <85cd91320ad71bd44d8d82aed52b29c2b08888ab.camel@gmail.com> (raw)
In-Reply-To: <CAPrE0SbBcD+adG_YLpphu3CjpVZUp7bXqJ6vxvxySX2vGpGMNw@mail.gmail.com>
References: <CAPrE0SYkp12Gd2Y0NVxTwvp_EpMymDa=i_vVQ3EZD11MOSJTRQ@mail.gmail.com>
	<dd0f5c95-08e0-f198-b59a-704377ccdcf7@aklaver.com>
	<87impio1tf.fsf@news-spur.riddles.org.uk>
	<91469459-36f7-41a4-09e9-c88d693cccef@aklaver.com>
	<CAPrE0SbBcD+adG_YLpphu3CjpVZUp7bXqJ6vxvxySX2vGpGMNw@mail.gmail.com>



On Wed, 2019-09-25 at 10:12 +1000, Paul McGarry wrote:
> 
> On Wed, Sep 25, 2019 at 5:44 AM Adrian Klaver <
> adrian.klaver@aklaver.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








view thread (9+ messages)  latest in thread

Message-ID: <85cd91320ad71bd44d8d82aed52b29c2b08888ab.camel@gmail.com>
Permalink:  ../85cd91320ad71bd44d8d82aed52b29c2b08888ab.camel@gmail.com/
Also on:    postgresql.org/message-id/85cd91320ad71bd44d8d82aed52b29c2b08888ab.camel@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: floriparob@gmail.com, paul@paulmcgarry.com, adrian.klaver@aklaver.com, andrew@tao11.riddles.org.uk
  Subject: Re: How to get timezone offset in timestamp with time zone AT TIME ZONE output.
  In-Reply-To: <85cd91320ad71bd44d8d82aed52b29c2b08888ab.camel@gmail.com>
  References: <CAPrE0SYkp12Gd2Y0NVxTwvp_EpMymDa=i_vVQ3EZD11MOSJTRQ@mail.gmail.com> <dd0f5c95-08e0-f198-b59a-704377ccdcf7@aklaver.com> <87impio1tf.fsf@news-spur.riddles.org.uk> <91469459-36f7-41a4-09e9-c88d693cccef@aklaver.com> <CAPrE0SbBcD+adG_YLpphu3CjpVZUp7bXqJ6vxvxySX2vGpGMNw@mail.gmail.com> <85cd91320ad71bd44d8d82aed52b29c2b08888ab.camel@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox