I run a macro in a Microsoft Access database to convert the data to MySQL. If a date field is empty in Access, it remains empty in the "Insert Record" code that is created by the macro, but when I insert the text file into MySQL, the date is changed to 00/00/0000. When I query the data and post it to a PHP results page on my website, I would like the date field to be blank rather than return 00/00/0000. Could anyone help me out with this? I can find all kinds of help for formatting date fields, etc. but nothing about this problem.
Thanks much for any assistance!
Date returned as 00/00/0000 rather than blank
Moderator: General Moderators
Different script solved the problem
I downloaded ExportSQL script from http://www.cynergi.net/exportsql/ and it worked great! It puts "Null" in as the value rather than leaving it blank and that took care of my problem. Thanks for the help.
When I want to display dates, but not the 0000-00-00 default that MySQL uses for NULL values, I use the following code to check the date and display nothing if appropriate:
Enjoy, in case you still need it!
Code: Select all
if ($date_variable != "0000-00-00") {
list($year, $month, $day) = split('ї-./]', $date_variable);
$date_variable = date('m/d/Y',mktime(0,0,0,$month,$day,$year));
}
else {
$date_variable = "";
}