Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 495362E00E7 for ; Wed, 30 Jan 2008 22:05:10 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 94395-03 for ; Wed, 30 Jan 2008 22:05:03 -0400 (AST) Received: from outbound1.ucsd.edu (outbound1.ucsd.edu [132.239.1.205]) by postgresql.org (Postfix) with ESMTP id D7F852E003A for ; Wed, 30 Jan 2008 22:05:02 -0400 (AST) Received: from smtp.ucsd.edu (smtp.ucsd.edu [132.239.1.49]) by outbound1.ucsd.edu (8.13.6/8.13.6) with ESMTP id m0V250ob038079 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 30 Jan 2008 18:05:01 -0800 (PST) DomainKey-Signature: a=rsa-sha1; s=2007001; d=ucsd.edu; c=simple; q=dns; b=Lt+YjezBMv1mGQUS8SJOAu/SPPvmGMxzvh9n9N4q1ShJ6mVh/MUYNkxV06I4DS/Fk uicEl5B7PVIXUXuHFcqEA== Received: from [137.110.115.155] (dyn137-110-115-155.ucsd.edu [137.110.115.155]) (authenticated bits=0) by smtp.ucsd.edu (8.13.6/8.13.6) with ESMTP id m0V24xkm065923 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 30 Jan 2008 18:05:00 -0800 (PST) X-Authentication-Warning: smtp.ucsd.edu: Host dyn137-110-115-155.ucsd.edu [137.110.115.155] claimed to be [137.110.115.155] Message-ID: <47A12CCB.1000807@ucsd.edu> Date: Wed, 30 Jan 2008 18:04:59 -0800 From: Luca Clementi User-Agent: Thunderbird 2.0.0.6 (X11/20071022) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: Problem with the to_timestamp function References: <47A10A1D.5020408@ucsd.edu> <27257.1201739170@sss.pgh.pa.us> In-Reply-To: <27257.1201739170@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/235 X-Sequence-Number: 30088 Tom Lane wrote: > Luca Clementi 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