Unix Technical Forum

Re: Problem with the to_timestamp function

This is a discussion on Re: Problem with the to_timestamp function within the pgsql Sql forums, part of the PostgreSQL category; --> Tom Lane wrote: > Luca Clementi <lclement@ucsd.edu> writes: >> I found the problem!! >> to_timestamp(start_time, 'M DD, YYYY HH12:MI:SS') ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Sql

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 06:00 PM
Luca Clementi
 
Posts: n/a
Default Re: Problem with the to_timestamp function

Tom Lane wrote:
> Luca Clementi <lclement@ucsd.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?


What do you mean with th standard input converter, you mean casting that
string into a date with the default locate format. This won't work,
because the machine where the DB is running is set to en.US, so it won't
be able to parse that date. That's why I am using the to_timestamp.

I am doning some data clean up in my DB.

Thanks again for your help,
Luca

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 06:00 PM
Tom Lane
 
Posts: n/a
Default Re: Problem with the to_timestamp function

Luca Clementi <lclement@ucsd.edu> writes:
> What do you mean with th standard input converter, you mean casting that
> string into a date with the default locate format. This won't work,
> because the machine where the DB is running is set to en.US, so it won't
> be able to parse that date. That's why I am using the to_timestamp.


Locale has nothing to do with this --- at most you might want to adjust
the datestyle parameter.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:12 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com