Thanks much for your help!
It took a few tries to get what it was all about, but I got it.
On Thursday 16 December 2004 14:09, Michael Fuhr wrote:
> > Dates are kept as ]YYYYMMDD', eg 2004114 for Nov 14, 2004.
>
> Why not use a DATE type? You can reformat it with to_char() if
> need be.
Not a bad idea. I used int because it was simple and "good enough". My app is
written in PHP, and by using strtotime() I can trap typo errors before they
get near the database (which frequently are difficult to display in a
layperson readable format)
EG:
$sql="INSERT INTO enrollments (date) values ('[date]')";
$pass=array('date'=>$_ENROLL['date'];
if (!$DB->SafeQuery($sql, $pass))
return error("Database Error: ".$DB->Error());
If there's an error here, it'd say something like: "ERROR: Bad date external
representation 'mya 11 2004'. Compare with:
$sql="INSERT INTO enrollments (date) VALUES [date]";
IF (($date=strtotime($_REQUEST['date'])) ==-1)
return Error("I'm sorry, but ".$_REQUEST['date']." does not appear to be a
valid date. Please fix and try again");
if (!$DB->SafeQuery($sql, array('date'=>$date)))
return error("Database Error: ".$DB->Error());
which is much more "friendly" to the end user.
BTW: What is to_char, and why doesn't this work in PG 7.3.x?
select to_char(datefield) from TableX;
-Ben
--
"The best way to predict the future is to invent it."
- XEROX PARC slogan, circa 1978