pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tom Kreiner <tom_kreiner@hotmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Getting Hour From a Time in Different Time Zone
Date: Thu, 03 Jan 2002 10:43:30 -0500
Message-ID: <12910.1010072610@sss.pgh.pa.us> (raw)
In-Reply-To: <F41s3bi6DigZBq9s8OV00014ba2@hotmail.com>
References: <F41s3bi6DigZBq9s8OV00014ba2@hotmail.com>

"Tom Kreiner" <tom_kreiner@hotmail.com> writes:
> SELECT hour(timestamp(current_timestamp AT TIME ZONE INTERVAL '-05 hours'));

The AT TIME ZONE construct produces a text string, which you are
converting back into a timestamp, which is internally just GMT --- all
notion that it had anything to do with EST time is gone.

You can actually get the above to work in 7.2, though.  It looks like
Thomas changed AT TIME ZONE to not emit timezone in the output string,
which avoids the rotation back to your own zone:


regression=# SELECT current_timestamp;
          timestamptz
-------------------------------
 2002-01-03 10:40:42.901964-05
(1 row)

regression=# SELECT current_timestamp AT TIME ZONE INTERVAL '-08 hours';
          timezone
----------------------------
 2002-01-03 07:40:49.452058
(1 row)

regression=# SELECT "timestamp"(current_timestamp AT TIME ZONE INTERVAL '-08 hours');
         timestamp
----------------------------
 2002-01-03 07:41:19.469686
(1 row)

regression=# SELECT extract(hour from "timestamp"(current_timestamp AT TIME ZONE INTERVAL '-08 hours'));
 date_part
-----------
         7
(1 row)

			regards, tom lane



view thread (2+ messages)

Message-ID: <12910.1010072610@sss.pgh.pa.us>
Permalink:  ../12910.1010072610@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/12910.1010072610@sss.pgh.pa.us

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, tom_kreiner@hotmail.com
  Subject: Re: Getting Hour From a Time in Different Time Zone
  In-Reply-To: <12910.1010072610@sss.pgh.pa.us>

* 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