Search Postgresql Archives

Re: to_timestamp() and timestamp without time zone

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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-TABLE for 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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux