Re: [GENERAL] to_timestamp() and quarters

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Brendan Jurd <direvus@gmail.com>
Cc: Bruce Momjian <bruce@momjian.us>, Scott Bailey <artacus@comcast.net>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2010-03-03T17:08:18Z
Lists: pgsql-hackers, pgsql-general
Brendan Jurd <direvus@gmail.com> writes:
> For example, you're trying to import a date that is written as "Wed
> 3rd March, Q1 2010".  You might give to_date a format string like 'Dy
> FMDDTH Month, "Q"Q YYYY' and expect to get the correct answer.  If we
> start throwing an error on the Q field, then users would have to
> resort to some strange circumlocution to get around it.

Hmm.  That's an interesting test case: if Q throws an error, there
doesn't seem to be any way to do it at all, because there is no format
spec for ignoring non-constant text.  Conversely, Bruce's proposed
patch would actually break it, because the Q code would overwrite the
(correct) month information with the first-month-of-the-quarter.

So at the moment my vote is "leave it alone".  If we want to throw
error for Q then we should provide a substitute method of ignoring
a field.  But we could just document Q as ignoring an integer for
input.

			regards, tom lane