Re: Problem with the to_timestamp function

From: Luca Clementi <lclement(at)ucsd(dot)edu>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Problem with the to_timestamp function
Date: 2008-01-31 02:04:59
Message-ID: 47A12CCB.1000807@ucsd.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Tom Lane wrote:
> Luca Clementi <lclement(at)ucsd(dot)edu> writes:
>> It seems that the to_timestamp does not work properly in this case,
>> when it comes to parsing the hours.
>
> to_timestamp() is not very robust if the input doesn't exactly match
> what it expects for the format string. I'm not sure if that's the
> issue here, but have you tried just casting the string to timestamp?
> That would use the standard timestamp input converter, which is
> pretty flexible.
>
> (BTW, there is definitely 0 hope of recognizing a timezone name that's
> written in Chinese characters, unless maybe you fool around with the
> timezone-abbreviations configuration file.)
>

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?

PS: some e-mail clients do not render properly the spacing in my first
e-mail.

Thanks again for your help!!
Luca

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2008-01-31 06:04:01 Re: Problem with the to_timestamp function
Previous Message Michael Glaesemann 2008-01-31 01:19:21 Re: Problem with the to_timestamp function