Re: to_timestamp() and timestamp without time zone

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Cc: hernan gonzalez <hgonzalez(at)gmail(dot)com>
Subject: Re: to_timestamp() and timestamp without time zone
Date: 2011-06-24 00:10:13
Message-ID: 201106231710.13935.adrian.klaver@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thursday, June 23, 2011 1:42:42 pm hernan gonzalez wrote:

> 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) .

To split hairs to_timestamp() parses a string and returns a timestamp with time
zone. What you want is a function that parses a string and does not editorialize
the result. FYI the code that handles this is located in the source at:
src/backend/utils/adt
as
formatting.c

>
> 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.

Might want to look at one of the non-pgsql languages that have their own
timezone/date handling code. Basically do an end run around Postgres.

>
> Regards
>
> Hernán J. González

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2011-06-24 00:48:05 wiki error
Previous Message David Johnston 2011-06-23 22:26:48 Re: unique across two tables