From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Brendan Jurd <direvus(at)gmail(dot)com>, Scott Bailey <artacus(at)comcast(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [GENERAL] to_timestamp() and quartersf |
Date: | 2010-03-03 17:22:21 |
Message-ID: | 201003031722.o23HMLo23065@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
Tom Lane wrote:
> Brendan Jurd <direvus(at)gmail(dot)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.
Here is an updated patch that honors 'Q' only if the month has not been
previously supplied:
test=> SELECT to_date('2010-3', 'YYYY-Q');
to_date
------------
2010-07-01
(1 row)
test=> SELECT to_date('2010-04-3', 'YYYY-MM-Q');
to_date
------------
2010-04-01
(1 row)
but it fails if a later month is specified:
test=> select to_date('2010-3-05', 'YYYY-Q-MM');
ERROR: conflicting values for "MM" field in formatting string
DETAIL: This value contradicts a previous setting for the same field type.
even if the month is in that quarter but not the first month of the
quarter.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
PG East: http://www.enterprisedb.com/community/nav-pg-east-2010.do
Attachment | Content-Type | Size |
---|---|---|
unknown_filename | text/plain | 1.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Brendan Jurd | 2010-03-03 17:22:52 | Re: [GENERAL] to_timestamp() and quarters |
Previous Message | Tom Lane | 2010-03-03 17:08:18 | Re: [GENERAL] to_timestamp() and quarters |
From | Date | Subject | |
---|---|---|---|
Next Message | Brendan Jurd | 2010-03-03 17:22:52 | Re: [GENERAL] to_timestamp() and quarters |
Previous Message | Tom Lane | 2010-03-03 17:08:18 | Re: [GENERAL] to_timestamp() and quarters |