From: | Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org, Reid(dot)Thompson(at)ateb(dot)com |
Subject: | Re: select to_timestamp('02/26/2011 14:50', 'MM/DD/YYYY HH24MI') |
Date: | 2011-02-25 14:50:13 |
Message-ID: | 201102250650.14190.adrian.klaver@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Friday, February 25, 2011 6:41:54 am Reid Thompson wrote:
> On 02/25/2011 09:30 AM, akp geek wrote:
> > Hi all -
> >
> > I have recently upgraded from 8.3 to 9.0.2.
> >
> > when I run the following sql in 9.0.2 " select
> > to_timestamp('02/26/2011 14:50', 'MM/DD/YYYY HH24MI') " I am getting the
> > following error and the sql runs fine in older version
> >
> > Is it my installation issue or library missing?
> >
> >
> > ERROR: invalid value ":5" for "MI"
> > DETAIL: Value must be an integer.
> >
> > ********** Error **********
> >
> > ERROR: invalid value ":5" for "MI"
> > SQL state: 22007
> > Detail: Value must be an integer.
> >
> >
> >
> > Thanks for the help
> > Regards
>
> military time doesn't have the ':' in the HHMM.
> look closely at your 'working' result, does it look like this?
>
>
> reporting=# select to_timestamp('02/26/2011 14:50', 'MM/DD/YYYY HH24MI');
> to_timestamp
> ------------------------
> 2011-02-26 14:00:00-05
> (1 row)
>
> reporting=# select to_timestamp('02/26/2011 1450', 'MM/DD/YYYY HH24MI');
> to_timestamp
> ------------------------
> 2011-02-26 14:50:00-05
> (1 row)
>
> Note the invalid time for the first result.
To confirm above I ran your query on 8.3.
Your original version:
test=# select to_timestamp('02/26/2011 14:50', 'MM/DD/YYYY HH24MI');
to_timestamp
------------------------
2011-02-26 14:00:00-08
(1 row)
Corrected for the ':':
test=# select to_timestamp('02/26/2011 14:50', 'MM/DD/YYYY HH24:MI');
to_timestamp
------------------------
2011-02-26 14:50:00-08
(1 row)
On 9.0.3 corrected for the ':':
test(5432)aklaver=>select to_timestamp('02/26/2011 14:50', 'MM/DD/YYYY
HH24:MI');
to_timestamp
------------------------
2011-02-26 14:50:00-08
(1 row)
Seems 9.0+ is stricter on its parsing.
--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2011-02-25 15:02:57 | Re: select to_timestamp('02/26/2011 14:50', 'MM/DD/YYYY HH24MI') |
Previous Message | akp geek | 2011-02-25 14:47:32 | Re: array size |