Re: How can one validate a date in mysql ?

2001-05-15 Thread Paul van den Berg

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




Re: How can one validate a date in mysql ?

2001-05-15 Thread Peter Pentchev

On Tue, May 15, 2001 at 11:27:19AM +0200, Vankeerberghen, Pieter wrote:
> Thank you, Ok, I looked in the manual but I coul dnot obtain an answer. How
> can I check that a date I'm importing is valid, e.g. how to check for
> 20001131 (MMDD) ?

You'll have to do this kind of validation checks in your actual program
that uses the MySQL interface, *before* executing the SQL statement itself.

G'luck,
Peter

-- 
"yields falsehood, when appended to its quotation." yields falsehood, when appended to 
its quotation.

-
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




RE: How can one validate a date in mysql ?

2001-05-15 Thread Vankeerberghen, Pieter

Thank you, Ok, I looked in the manual but I coul dnot obtain an answer. How
can I check that a date I'm importing is valid, e.g. how to check for
20001131 (MMDD) ?

Kind regards,
Pieter

-Original Message-
From: Colin Faber [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 15, 2001 11:18 AM
To: Vankeerberghen, Pieter
Cc: [EMAIL PROTECTED]
Subject: Re: How can one validate a date in mysql ?


Validate a date?

see Date and Time functions in the manual.


"Vankeerberghen, Pieter" wrote:
> 
> Dear Colleagues,
> 
> How can one validate a date in mysql ?
> 
> Kind regards,
> Pieter



Re: How can one validate a date in mysql ?

2001-05-15 Thread Colin Faber

Validate a date?

see Date and Time functions in the manual.


"Vankeerberghen, Pieter" wrote:
> 
> Dear Colleagues,
> 
> How can one validate a date in mysql ?
> 
> Kind regards,
> Pieter

-
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