Re: Re: to_timestamp returns the incorrect result for the DST fall over time.

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Gouse <gkhaji(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Re: to_timestamp returns the incorrect result for the DST fall over time.
Date: 2011-01-06 03:38:03
Message-ID: AANLkTi=1ZF+XjUcfZizLDE8MNFtf+u5GfL1nf0=gMGeP@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Jan 5, 2011 at 6:10 AM, Gouse <gkhaji(at)gmail(dot)com> wrote:
> // snippet of the stored procedure...
> CREATE OR REPLACE FUNCTION wf_to_timestamp("varchar")
>  RETURNS timestamptz AS
> $BODY$
>  select to_timestamp($1,'YYYY-MM-DD HH24:MI:SS.MS')+ interval '1 hour' *
> (extract(timezone from to_timestamp($1,'YYYY-MM-DD HH24:MI:SS.MS')) /
> 3600.0)
> $BODY$
>  LANGUAGE 'sql' VOLATILE;
> ALTER FUNCTION wf_to_timestamp("varchar") OWNER TO postgres;
>
> When I pass the UTC time '2010-03-28 01:00:03 243'  I should expect the
> output to be '2010-03-28 02:00:03.243 + 01'  , instead I am getting the
> result '2010-03-28 03:00:03.243 + 01'.
>
> The store procedure works well for the UTC time starting from '2010-03-28
> 02:00:00 000'. The problem only lies for the UTC time period  from
> '2010-03-28 01:00:00 000' to '2010-03-28 01:59:59 999'.

How about something like this:

create or replace function x(text) returns timestamptz as $$select
to_timestamp($1,'YYYY-MM-DD HH24:MI:SS.MS')$$ set timezone = 'UTC'
language sql;

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Dave Page 2011-01-06 09:30:07 Re: BUG #5807: psql fails to launch with "Cannot read termcap database; using dumb terminal settings. Aborted"
Previous Message jengeno 2011-01-05 22:02:53 BUG #5817: Language problem...