List:General Discussion« Previous MessageNext Message »
From:Martin Ramsch Date:September 28 1999 3:12pm
Subject:Re: <no subject>
View as plain text  
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.

Regards,
  Martin
-- 
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
Thread
<no subject>Jeppe Sohn Jensen28 Sep
Re: <no subject>Martin Ramsch28 Sep
Re: <no subject>Bob Kline28 Sep
Re: <no subject>bpaduraru28 Sep