On Tue, 1999-09-28 15:35:16 +0200, Jeppe Sohn Jensen wrote:
> How can i be shure that the date format is right? If i type a wrong
> date eg. 1999-13-32 it will show as 0000-00-00 in the table.
> Can i do a date check insert before i insert the data??
You always could do such checks in your application, but if you want
to use MySQLs date functions you might try a query like:
SELECT '1999-13-32' = FROM_DAYS(TO_DAYS('1999-12-31'));
If the result is NULL, then TO_DAYS didn't accept this date and the
date is mal-formed,
if it's 0 (false), then the date looks like a date, but is a
non-existant date like 1999-11-31 (only 30 days in November!),
and only if the result is 1 (true), then date is okay.
Martin Ramsch <m.ramsch@stripped> <URL: http://home.pages.de/~ramsch/ >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26 E4 EC 80 58 7B 31 3A D7