From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "Belinda M(dot) Giardine" <giardine(at)bio(dot)cse(dot)psu(dot)edu>, Erik Jones <erik(at)myemma(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: date comparisons |
Date: | 2007-02-03 23:46:56 |
Message-ID: | 200702032346.l13Nkut23682@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-patches |
Would someone please confirm that our behavior in the three queries
below matches Oracle's behavior?
---------------------------------------------------------------------------
Tom Lane wrote:
> "Belinda M. Giardine" <giardine(at)bio(dot)cse(dot)psu(dot)edu> writes:
> > Should it be this way?
>
> Well, to_timestamp() is apparently designed not to complain when the
> input doesn't match the format, which is not my idea of good behavior
> ... but your example is in fact wrong. 'Month' means a 9-character
> field, so you are short a couple of spaces.
>
> regression=# select to_timestamp('January 2006', 'Month YYYY');
> to_timestamp
> ------------------------
> 0006-01-01 00:00:00-05
> (1 row)
>
> regression=# select to_timestamp('January 2006', 'Month YYYY');
> to_timestamp
> ------------------------
> 2006-01-01 00:00:00-05
> (1 row)
>
> You probably want
>
> regression=# select to_timestamp('January 2006', 'FMMonth YYYY');
> to_timestamp
> ------------------------
> 2006-01-01 00:00:00-05
> (1 row)
>
> Or, as suggested upthread, forget to_timestamp and just use the native
> timestamp or date input conversion, which on the whole is a lot more
> robust (it *will* throw an error if it can't make sense of the input,
> unlike to_timestamp).
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
--
Bruce Momjian bruce(at)momjian(dot)us
EnterpriseDB http://www.enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
From | Date | Subject | |
---|---|---|---|
Next Message | Chad Wagner | 2007-02-04 00:01:40 | Re: date comparisons |
Previous Message | elein | 2007-02-03 23:10:26 | Re: Can a function be parameter in PL/PGSQL function? |
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2007-02-03 23:58:14 | Re: Dead code in _bt_split? |
Previous Message | Andrew Dunstan | 2007-02-03 19:54:24 | Re: [HACKERS] \copy (query) delimiter syntax error |