pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Aasmund Midttun Godal <postgresql@envisity.com>
Cc: pgsql-sql@postgresql.org, Karel Zak <zakkr@zf.jcu.cz>
Subject: Re: Unpredictable text -> date implicit casting behaviour/to_date bug
Date: Mon, 31 Dec 2001 11:02:47 -0500
Message-ID: <12926.1009814567@sss.pgh.pa.us> (raw)
In-Reply-To: <20011231143815.8427.qmail@213-145-170-138.dd.nextgentel.com>
References: <20011231143815.8427.qmail@213-145-170-138.dd.nextgentel.com>

"Aasmund Midttun Godal" <postgresql@envisity.com> writes:
> The implicit casting of text to date is normally quite good, however i
> think it should only use one method during a given query (or maybe
> transaction?)

Try setting DateStyle to match the date style you are using.  Postgres
is doing the best it can with ambiguous input.

> Added to the fact that to_date has a bug:

> SELECT ordredato, ordredato::date, to_date(ordredato, 'DD.MM.YY') from old_faktura where status = 'ANN';
>  ordredato |  ?column?  |    to_date    
> -----------+------------+---------------
>  18.04.00  | 2000-04-18 | 0001-04-18 BC
>  30.08.01  | 2001-08-30 | 2001-08-30
>  18.04.00  | 2000-04-18 | 0001-04-18 BC

I agree, this is not desired behavior.  The problem seems to be that the
logic in to_timestamp() tries to use "field is not zero" as a substitute
test for "field was provided".  At least in the case of the year fields,
this is *not* workable.  There must be a separate flag bit.

			regards, tom lane



view thread (5+ messages)  latest in thread

Message-ID: <12926.1009814567@sss.pgh.pa.us>
Permalink:  ../12926.1009814567@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/12926.1009814567@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, postgresql@envisity.com, zakkr@zf.jcu.cz
  Subject: Re: Unpredictable text -> date implicit casting behaviour/to_date bug
  In-Reply-To: <12926.1009814567@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox