Re: to_timestamp() and timestamp without time zone - Mailing list pgsql-general

From Adrian Klaver
Subject Re: to_timestamp() and timestamp without time zone
Date
Msg-id 201106231710.13935.adrian.klaver@gmail.com
Whole thread Raw
In response to Re: to_timestamp() and timestamp without time zone  (hernan gonzalez <hgonzalez@gmail.com>)
List 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.klaver@gmail.com

pgsql-general by date:

Previous
From: "David Johnston"
Date:
Subject: Re: unique across two tables
Next
From: John R Pierce
Date:
Subject: wiki error