Re: to_timestamp() and timestamp without time zone

From: hernan gonzalez <hgonzalez(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: to_timestamp() and timestamp without time zone
Date: 2011-06-23 20:42:42
Message-ID: BANLkTikb1_A6GjmuVPxzDvzbjR=pJ3=yvA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>
>
> Every example here starts, at its core, with to_timestamp. That function
> returns a timestamp *with* time zone so of-course the current timezone
> setting will influence it. Stop using it - it doesn't do what you want.
>
> If you cast directly to a timestamp *without* time zone you can take
> advantage of the many formats PostgreSQL supports.
>
> See:
> http://www.postgresql.org/docs/9.0/interactive/datatype-datetime.html#DATATYPE-DATETIME-DATE-TABLEfor supported formats. Note also that you can use "set datestyle" to match
> your MDY or DMY date formatting.
>
>
Fair enough: to_timestamp doesn't do what I want, I must resort to casting.

But it's rather unfortunate that a to_timestamp() function doesnt actually
parse a "timestamp" (which, is a alias to "timestamp without timezone", at
least since PG 7.3) .

BTW, the "set datestyle" workaround can be umpractical in some scenarios
(case in point: I have a view that returns some column as "timestamp" by
doing that parsing from a text colum ) I even can't put a "SET DATESTYLE"
(or a SET TIMEZONE=UTC)" in a function, unless I make it VOLATILE, which I
certainly would not like.

Regards

Hernán J. González

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2011-06-23 21:45:56 Re: to_timestamp() and timestamp without time zone
Previous Message Tomas Vondra 2011-06-23 20:39:44 Re: unique across two tables