BUG #6340: to_timestamp() miscalculates

Started by Hans-Henrik Fuxeliusover 14 years ago6 messagesbugs
Jump to latest
#1Hans-Henrik Fuxelius
hfuxelius@gmail.com

The following bug has been logged on the website:

Bug reference: 6340
Logged by: Hans-Henrik Fuxelius
Email address: hfuxelius@gmail.com
PostgreSQL version: 9.1.1
Operating system: Ubuntu 11.10
Description:

test to run: select to_timestamp('2011,03,27,02,11,11',
'YYYY,MM,DD,HH24,MI,SS')

and the run: select to_timestamp('2011,03,27,03,11,11',
'YYYY,MM,DD,HH24,MI,SS')

It miscalculates 02 hour to 03 hour by some reason

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Hans-Henrik Fuxelius (#1)
Re: BUG #6340: to_timestamp() miscalculates

hfuxelius@gmail.com writes:

test to run: select to_timestamp('2011,03,27,02,11,11',
'YYYY,MM,DD,HH24,MI,SS')

and the run: select to_timestamp('2011,03,27,03,11,11',
'YYYY,MM,DD,HH24,MI,SS')

It miscalculates 02 hour to 03 hour by some reason

If that date is a DST forward transition date in your timezone, then
this behavior is neither surprising nor a bug.

regards, tom lane

#3Kevin Grittner
Kevin.Grittner@wicourts.gov
In reply to: Tom Lane (#2)
Re: BUG #6340: to_timestamp() miscalculates

wrote:

test to run: select to_timestamp('2011,03,27,02,11,11',
'YYYY,MM,DD,HH24,MI,SS')

and the run: select to_timestamp('2011,03,27,03,11,11',
'YYYY,MM,DD,HH24,MI,SS')

It miscalculates 02 hour to 03 hour by some reason

I don't know what time zone you're in, or whether daylight saving
time kicks in on that date. *Is* there a 02:11:11 on that date, or
is that when time "springs forward" by an hour in the spring for your
locale?

-Kevin

#4Hans-Henrik Fuxelius
hfuxelius@gmail.com
In reply to: Kevin Grittner (#3)
Re: BUG #6340: to_timestamp() miscalculates

Thanx a lot for your promt respons :) You are absolutely right, its the daylight saving that date and hour, I had it as an key in my GPS data and was very confused!!!

Again - Thanx
/Hans-Henrik
On Dec 15, 2011, at 5:20 PM, Kevin Grittner wrote:

Show quoted text

wrote:

test to run: select to_timestamp('2011,03,27,02,11,11',
'YYYY,MM,DD,HH24,MI,SS')

and the run: select to_timestamp('2011,03,27,03,11,11',
'YYYY,MM,DD,HH24,MI,SS')

It miscalculates 02 hour to 03 hour by some reason

I don't know what time zone you're in, or whether daylight saving
time kicks in on that date. *Is* there a 02:11:11 on that date, or
is that when time "springs forward" by an hour in the spring for your
locale?

-Kevin

#5Hans-Henrik Fuxelius
hfuxelius@gmail.com
In reply to: Hans-Henrik Fuxelius (#4)
Re: BUG #6340: to_timestamp() miscalculates

It seems not possible to suppress to_timestamp from doing daylight
saving conversion, I have GPS timeseries that looks perfect in the
'timestamp without time zone' save one value that wreck the whole time
serie, does that mean that time series cant be stored in time stamps?

/Hans-Henrik

On Thu, Dec 15, 2011 at 5:56 PM, Hans-Henrik Fuxelius
<hfuxelius@gmail.com> wrote:

Show quoted text

Thanx a lot for your promt respons :) You are absolutely right, its the daylight saving that date and hour, I had it as an key in my GPS data and was very confused!!!

Again - Thanx
/Hans-Henrik
On Dec 15, 2011, at 5:20 PM, Kevin Grittner wrote:

wrote:

test to run: select to_timestamp('2011,03,27,02,11,11',
'YYYY,MM,DD,HH24,MI,SS')

and the run: select to_timestamp('2011,03,27,03,11,11',
'YYYY,MM,DD,HH24,MI,SS')

It miscalculates 02 hour to 03 hour by some reason

I don't know what time zone you're in, or whether daylight saving
time kicks in on that date.  *Is* there a 02:11:11 on that date, or
is that when time "springs forward" by an hour in the spring for your
locale?

-Kevin

#6Robert Haas
robertmhaas@gmail.com
In reply to: Hans-Henrik Fuxelius (#5)
Re: BUG #6340: to_timestamp() miscalculates

On Fri, Dec 16, 2011 at 3:43 AM, Hans-Henrik Fuxelius
<hfuxelius@gmail.com> wrote:

It seems not possible to suppress to_timestamp from doing daylight
saving conversion, I have GPS timeseries that looks perfect in the
'timestamp without time zone' save one value that wreck the whole time
serie, does that mean that time series cant be stored in time stamps?

I think it mostly means that you shouldn't use timestamp without time zone.

Or else you should use a time zone setting that doesn't involve DST.

Throwing away the time zone information is bad, because YYYY-MM-DD
HH:MM:SS doesn't uniquely identify a point in time, even if you know
what time zone it's relative to. That combination of years, minutes,
days, hours, minutes, and seconds can occur twice, if it's near a DST
boundary.

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