Re: Problem with the to_timestamp function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Luca Clementi <lclement(at)ucsd(dot)edu>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Problem with the to_timestamp function
Date: 2008-01-31 06:04:01
Message-ID: 751.1201759441@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Luca Clementi <lclement(at)ucsd(dot)edu> writes:
> I found the problem!!
> to_timestamp(start_time, 'M DD, YYYY HH12:MI:SS')
> in the formatting string I have two spaces, while in the original there
> is only one:
> 1 28, 2008 12:23:19

> So if I use: 'M DD, YYYY HH12:MI:SS' as a formatting string it works!
> I wander how come if the formatting string doesn't match properly you
> get such a bad behavior, would it better just a error?

Yeah, it should either do something reasonable or throw an error.
Improving to_timestamp's handling of such cases is on the TODO list.
In the meantime, though, the standard input converter is a whole lot
more flexible for slightly-out-of-spec input ... so I ask again,
do you really need to_timestamp at all?

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Luca Clementi 2008-01-31 18:00:10 Re: Problem with the to_timestamp function
Previous Message Luca Clementi 2008-01-31 02:04:59 Re: Problem with the to_timestamp function