> Dear Colleagues,
>  
> How can one validate a date in mysql ?
>  
> Kind regards,
> Pieter
>
The simplest way that i know is:
 date_add(datestring, interval 0 day) 
This function wil return the correct date or NULL with months outside 1..12 
and days outside 1..31.
Here are some examples:
select date_add('1999023', interval 0 day) -> null
select date_add('19990223', interval 0 day) ->1999-02-23
select date_add('19990232', interval 0 day) -> null
select date_add('19990231', interval 0 day) ->1999-03-03 

Regards, Paul


Paul B. van den Berg               email: [EMAIL PROTECTED]
Department of Social Pharmacy and Pharmacoepidemiology
University Centre for Pharmacy     tel:31-50-3633331 fax:31-50-3632772
Ant. Deusinglaan 1  9713 AV Groningen  Netherlands

---------------------------------------------------------------------
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