MySQL: How to check if a string is a valid DATE, TIME or DATETIME

Posted by Svish on Stack Overflow See other posts from Stack Overflow or by Svish
Published on 2010-04-22T11:10:20Z Indexed on 2010/04/22 11:13 UTC
Read the original article Hit count: 175

Filed under:
|
|
|

When I try to put a value into a DATE field which is invalid, MySQL seems to use 0000-00-00 instead. Is there a way I can do this "check" without updating a DATE field? And to do it from for example PHP?

Like, is there a way I can query the MySQL server and ask "Hey, is this DATE, TIME or DATETIME valid to you?"

Or is there maybe an even better way of doing it?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about php