pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Aasmund Midttun Godal <postgresql@envisity.com>
To: pgsql-sql@postgresql.org
Subject: Unpredictable text -> date implicit casting behaviour/to_date bug
Date: Mon, 31 Dec 2001 14:38:15 GMT
Message-ID: <20011231143815.8427.qmail@213-145-170-138.dd.nextgentel.com> (raw)

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?) or maybe it should give a notice of some sort? - i was quite astonished when I discovered the following: (look closely at row 4 and 5 vs the others)

SELECT ordredato, ordredato::date from old_faktura where status = 'ORD';
 ordredato |  ?column?  
-----------+------------
 18.10.01  | 2001-10-18
 31.10.01  | 2001-10-31
 01.11.01  | 2001-01-11
 03.11.01  | 2001-03-11
 03.11.01  | 2001-03-11
 10.11.01  | 2001-10-11
 26.11.01  | 2001-11-26


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

It sometimes makes converting dates a little challenge...

Aasmund Midttun Godal

aasmund@godal.com - http://www.godal.com/
+47 40 45 20 46



view thread (5+ messages)  latest in thread

Message-ID: <20011231143815.8427.qmail@213-145-170-138.dd.nextgentel.com>
Permalink:  ../20011231143815.8427.qmail@213-145-170-138.dd.nextgentel.com/
Also on:    postgresql.org/message-id/20011231143815.8427.qmail@213-145-170-138.dd.nextgentel.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: postgresql@envisity.com
  Subject: Re: Unpredictable text -> date implicit casting behaviour/to_date bug
  In-Reply-To: <20011231143815.8427.qmail@213-145-170-138.dd.nextgentel.com>
  References: <20011231143815.8427.qmail@213-145-170-138.dd.nextgentel.com>

* 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