From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | Peter Nixonn <listuser(at)peternixon(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: converting timstamptz to local time zone |
Date: | 2006-03-30 11:38:07 |
Message-ID: | 20060330113807.GA16142@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, Mar 30, 2006 at 02:24:55PM +0300, Peter Nixonn wrote:
> How can I "select ('2006-01-01 9:00:00+02' at time zone 'GMT')::timestamp;"
> where instead of GMT it has the local time zone of the machine I am running
> it on (which varies between my machines)?
> I dont want to hard code the timezone of the machine into the query.. I want
> to pick it up from the environment, but cant figure out how :-(
Just cast it to 'timestamp', that uses the configured timezone:
test=# set timezone='Europe/Amsterdam';
SET
test=# select '2006-01-01 9:00:00+02'::timestamptz::timestamp;
timestamp
---------------------
2006-01-01 08:00:00
(1 row)
test=# set timezone='Australia/Sydney';
SET
test=# select '2006-01-01 9:00:00+02'::timestamptz::timestamp;
timestamp
---------------------
2006-01-01 18:00:00
(1 row)
Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Fuhr | 2006-03-30 11:40:48 | Re: How to detect primary key of a table |
Previous Message | Tino Wildenhain | 2006-03-30 11:30:56 | Re: How to detect primary key of a table |