Re: dealing with invalid date

From: Mike Nolan <nolan(at)gw(dot)tssi(dot)com>
To: mage(at)mage(dot)hu (Mage)
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: dealing with invalid date
Date: 2004-10-17 03:50:58
Message-ID: 200410170350.i9H3oxCe011801@gw.tssi.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> can pgsql acceppt invalid date values? Sometimes it would be nice to
> convert 2003-02-29 to 2003-03-01 or to 2003-02-28 automatically instead
> of throwing back an error message.

I guess the question is 'accept from where?'

This isn't a database question as much as it is a data INPUT question.

Take it from one who has spent 30 years dealing with user data, you DO NOT
WANT 'bad' data in your database, you want to clean it up before it
gets into the database, and you probably don't want the database
back end making decisions about how to fix data problems, because what
it does might not be what you want. What's the best corrected value
for the date string '13/34/2004'? Beats me! Sometimes the best answer is
"I don't know what you really mean here, try again."

You can certainly define a clean_date function in pl/pgsql (among other
choices) to take a string and fix whatever you want to fix before
converting it to a date. You can also do that in perl or PHP or whatever
it is you're writing the user interface in. Making the decision of when
and how to do that is a large part what I consider my 'value added' role
in designing a database system for a client.
--
Mike Nolan

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-10-17 03:56:58 Re: pgsql function using C++?, or at least C interfacing with C++ lib?
Previous Message Doug McNaught 2004-10-17 03:26:43 Re: dealing with invalid date