Date Validation?

From: "Josh Berkus" <josh(at)agliodbs(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Date Validation?
Date: 2001-07-13 15:24:36
Message-ID: web-85340@davinci.ethosmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Folks,

Pardon me for asking this again, but I received *no* responses last
week.

Question: Is there any function or method which will allow me, in SQL
or PL/pgSQL, to validate dates without raising an error for invalid
dates?

Expansion: I have a number of PL/pgSQL functions which must accept
dates as parameters from the PHP4 interface. There is, however, the
possibility that an invalid date will be passed, such as "2001-02-31"
due to the nature of HTML forms date selector.
What I would like to do is accept the date as a VARCHAR parameter, and
then validate it and convert it to a date inside the function if it
passes validation.
However, all validation methods I've tried, such as ISFINTTE and
TO_DATE produce SQL errors if the date is not valid; this causes the
function to error out and the user gets an unfriendly error message
which I have not control over. This is unacceptable. Obviously, one
answer is error-handling inside functions, but we won't get that until
7.2 as far as I know.
I could write a complicated string-parsing function to test the
validity of each part of the date, but that would a) lock the interface
into passing the dates in only one format, and b) be really complicated
for leap years and the millenium.
I am hoping that someone has already dealt with this issue in a way
that date validation can be trappable.

Thanks for your advice.

-Josh Berkus

______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh(at)agliodbs(dot)com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco

Attachment Content-Type Size
unknown_filename text/plain 2 bytes
unknown_filename text/plain 2 bytes
unknown_filename text/plain 2 bytes

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2001-07-13 15:43:54 Re: How can we match a condition among 2 diff. tables?
Previous Message Josh Berkus 2001-07-13 15:14:22 Re: Referencing a view?