| From: | "Belinda M(dot) Giardine" <giardine(at)bio(dot)cse(dot)psu(dot)edu> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | Erik Jones <erik(at)myemma(dot)com>, pgsql-general(at)postgresql(dot)org |
| Subject: | Re: date comparisons |
| Date: | 2006-12-12 17:39:00 |
| Message-ID: | Pine.GSO.4.53.0612121235540.28737@galapagos.bx.psu.edu |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general pgsql-patches |
On Tue, 12 Dec 2006, 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)
Thanks. I wanted to understand the reason for my attempt not working no
matter which method I used in the end. Help to prevent future errors.
>
> 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
Good to know.
Belinda
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ron Johnson | 2006-12-12 17:42:19 | Re: Why DISTINCT ... DESC is slow? |
| Previous Message | Tom Lane | 2006-12-12 17:30:07 | Re: Why DISTINCT ... DESC is slow? |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2006-12-12 17:47:50 | Re: Load distributed checkpoint |
| Previous Message | Gregory Stark | 2006-12-12 17:38:18 | Re: Load distributed checkpoint |