Skip site navigation (1) Skip section navigation (2)

to_timestamp not stable if date string shorter than template

From: "Stacy White" <harsh(at)computer(dot)org>
To: <pgsql-bugs(at)postgresql(dot)org>
Cc: "Aaron Harsh" <ajh(at)rentrak(dot)com>
Subject: to_timestamp not stable if date string shorter than template
Date: 2003-09-01 20:34:11
Message-ID: 000701c370c8$67738560$0200a8c0@grownups (view raw or flat)
Thread:
Lists: pgsql-bugs
Architecture: Intel Pentium
Operating System: Redhat 7.2 (Linux 2.4.17)
PostgreSQL version: PostgreSQL-7.3.4
Compiler used: gcc 3.01

to_timestamp appears to pick up the time-of-day from the previous call's
return value if a date string has no time component.  For example:

# select to_timestamp('2003-06-01', 'YYYY-MM-DD HH24:MI:SS') ;
      to_timestamp
------------------------
 2003-06-01 00:00:00-07
(1 row)

# select to_timestamp('2003-06-02 12:13:14', 'YYYY-MM-DD HH24:MI:SS') ;
      to_timestamp
------------------------
 2003-06-02 12:13:14-07
(1 row)

# select to_timestamp('2003-06-01', 'YYYY-MM-DD HH24:MI:SS') ;
      to_timestamp
------------------------
 2003-06-01 12:13:14-07
(1 row)

I suppose the proper behavior in this situation is debatable, but it seems
that the function should be stable.

FWIW, Oracle's behavior in this case (with 'to_date') is to return
'2003-06-01 00:00:00'.


Responses

pgsql-bugs by date

Next:From: Guy ThornleyDate: 2003-09-01 23:48:59
Subject: Re: Vacuum I/O throttling
Previous:From: Bruce MomjianDate: 2003-09-01 16:57:36
Subject: Re: session variable

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group