pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: lstrupinskaya@gmail.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #12739: to_timestamp function conver string to time incorrectly
Date: Fri, 06 Feb 2015 18:12:49 -0500
Message-ID: <27550.1423264369@sss.pgh.pa.us> (raw)
In-Reply-To: <20150205212231.24252.12016@wrigleys.postgresql.org>
References: <20150205212231.24252.12016@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

lstrupinskaya@gmail.com writes:
> When trying to use to_timestamp function to convert string '3/10/2013 2:30'
> to timestamp it was actually converted into 3/10/2013 3:30.

> Below is select statement:

> select to_timestamp('3/10/2013 2:30','MM/DD/YYYY HH24:MI');

If you're running with USA DST rules, there was no such thing as 2:30
observed local time on that date: clocks advanced from 1:59:59 to 3:00:00.

As documented, Postgres handles invalid or ambiguous times near a DST
transition by supposing that the given time is local standard time.
So in the New York zone for instance, 2:30 local standard time (GMT-5)
would equate to 3:30 local daylight time (GMT-4), and daylight time would
have been what was observed at that instant, so that's what gets printed.

If you don't want DST-aware handling of timestamps, don't use type
timestamptz nor to_timestamp (which actually produces timestamptz).

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (2+ messages)

Message-ID: <27550.1423264369@sss.pgh.pa.us>
Permalink:  ../27550.1423264369@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/27550.1423264369@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, lstrupinskaya@gmail.com
  Subject: Re: BUG #12739: to_timestamp function conver string to time incorrectly
  In-Reply-To: <27550.1423264369@sss.pgh.pa.us>
  References: <20150205212231.24252.12016@wrigleys.postgresql.org> <27550.1423264369@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox