11-20-2007, 02:38 AM
When a datetime field in the DB is empty, it returns 0000-00-00 00:00:00. When I display this field I don't want anything to show. Other than doing an IF...then check for that pattern, is there a better way to convert this to a blank?
11-20-2007, 02:53 AM
I can't think of a better way than IF.
11-20-2007, 03:18 AM
I just wasn't sure if there was a built-in method or something else that I could use.
11-20-2007, 03:29 AM
IF() is built-in. :p You may want to post this in, or ask it to be moved to, the MySQL forum.
11-20-2007, 03:24 PM
You can also use IFNULL() to give it a more descriptive result such as 'None' or 'N/A'.
11-20-2007, 05:21 PM
I was going to suggest that, but I tested it and MySQL doesn't seem to consider '0000-00-00 00:00:00' to be NULL, even if the field is datetime.
11-20-2007, 05:27 PM
I have to admit I didn't test it. I was drawing on Oracle experience (where such a date would be NULL). I wonder why MySQL doesn't consider that NULL.