> -----Original Message-----
> From: Artem Koutchine [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, January 21, 2001 1:44 PM
> To: [EMAIL PROTECTED]
> Subject: Checking if a date is correct
> 
> 
> try doing
> "SELECT UNIX_TIMESTAMP('1990-2-31')"
> and you'll get a number.
> This is very weird, since this is an incorrect date.

This is the documented behavior. Section 7.4.6 of the manual:

        "To make the date checking 'fast', MySQL only checks that 
        the month is in the range of 0-12 and the day is in the range 
        of 0-31" ... "This is extremely useful for applications that need 
        to store a birth-date for which you don't know the exact date. 
        In this case you simply store the date like 1999-00-00 or 
        1999-01-00. (You can of course not expect to get a correct value 
        from functions like DATE_SUB() or DATE_ADD for dates like these)."

> 
> Is there any way to figure out if a date is correct in mysql
> SQL implementation? 

No. You must check this yourself before entering the information
into the database. Most programming languages have this facility
built in.

> And why UNIX_TIMESTAMP does
> not return NULL for incorrect date?

See above.

/ Carsten
--
Carsten H. Pedersen
keeper and maintainer of the bitbybit.dk MySQL FAQ
http://www.bitbybit.dk/mysqlfaq



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to