Re: to_date function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Carlos Henrique Reimer <carlos(dot)reimer(at)opendb(dot)com(dot)br>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: to_date function
Date: 2010-07-07 21:43:26
Message-ID: 16331.1278539006@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Carlos Henrique Reimer <carlos(dot)reimer(at)opendb(dot)com(dot)br> writes:
> I've a Linux box running postgresql 8.2.17 and facing some strange results
> from the to_date function.

> As you can see in the following tests the problem occurs when the template
> used includes upper and lower case characters for the minute (Mi or mI).

> Am I using the incorrect syntax or is it a bug?

The defined template patterns are MI and mi. Random combinations of case
aren't accepted. I believe what's actually happening is that the code
is seeing this as separate letters m (which matches nothing so it's not
a template pattern but just constant text) and i or I, which are the
ISO-week patterns. More recent versions of PG throw an error

ERROR: invalid combination of date conventions
HINT: Do not mix Gregorian and ISO week date conventions in a formatting template.

but 8.2 probably just does something not too sensible with trying to
combine the ISO and Gregorian field values :-(

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kevin Grittner 2010-07-07 21:55:26 Re: Anyone in Madison?
Previous Message Ludwig Kniprath 2010-07-07 21:40:33 Re: to_date function