Re: Assigning a timestamp without timezone to a timestamp

From: chrisj <chrisj(dot)wood(at)sympatico(dot)ca>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Assigning a timestamp without timezone to a timestamp
Date: 2006-10-14 21:42:39
Message-ID: 6815181.post@talk.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


Hi Andrew,

Finally got around to trying to implement your solution.

It works fine with fixed offset timezones, but when I try it with EST5EDT
I get the following:
protocal2=> select start_datetime,cast(cast(cast(start_datetime as
timestamp(0) without time zone) as varchar)||' '||B.timezone_ch as
timestamp(0) with time zone) from reservation A, location B where appt_key
= 7 and locn_key = 102 ;
ERROR: invalid input syntax for type timestamp with time zone: "2006-07-13
09:20:00 EST5EDT"

when I change timezone_ch to EST it works like a charm:
protocal2=> select start_datetime,cast(cast(cast(start_datetime as
timestamp(0) without time zone) as varchar)||' '||B.timezone_ch as
timestamp(0) with time zone) from reservation A, location B where appt_key
= 7 and locn_key = 102 ;
start_datetime | timestamptz
------------------------+------------------------
2006-07-13 09:20:00-04 | 2006-07-13 10:20:00-04
(1 row)

Any thoughts?

On Thu, Oct 05, 2006 at 01:06:00PM -0700, chrisj wrote:
> If only all time zones were fixed offset timezones life would be so much
> simpler.

Indeed.

> Unfortunately the main area of deployment of my app will beToronto which
> is
> on EDT which is not a fixed offsets timezone. I hope/assume your solution
> works with "EDT" instead of "-3", I will test it soon.

Should do, although you'll need more than EDT. EDT is also fixed:
it's UTC-4. EST5EDT isn't, though, so you could use that (you'd need
to improve your schema, though, because you had char(3) there, and
not all time zones are 3 characters long). But to answer your
question, yes, it works. I just tried it.

A

--
Andrew Sullivan | ajs(at)crankycanuck(dot)ca
Information security isn't a technological problem. It's an economics
problem.
--Bruce Schneier

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
message can get through to the mailing list cleanly

--
View this message in context: http://www.nabble.com/Assigning-a-timestamp-without-timezone-to-a-timestamp-with-timezone-tf2373845.html#a6815181
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2006-10-14 23:26:32 Re: Assigning a timestamp without timezone to a timestamp
Previous Message Markus Schaber 2006-10-14 13:52:04 Re: Foreign key reference counting strategy?