kahodges Posted April 7, 2010 Share Posted April 7, 2010 I have the following code: $sql .=" where ( `date` is null or trim(`date`) = '' ) "; I'm using MySQL date format, which is 0000-00-00. When the field is left blank, it leaves 0000-00-00 instead of null. Is there another way around this? If there's an entry in that field instead of null, it causes my php script to not display an entry on the screen. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/197872-null-date-in-mysql/ Share on other sites More sharing options...
JonnoTheDev Posted April 7, 2010 Share Posted April 7, 2010 When inserting records and there is no date you should set the field to null, otherwise you end up with 0000-00-00 SET date=NULL Do a mass update on your table to clear the bad records UPDATE table SET date=NULL WHERE date='0000-00-00' Quote Link to comment https://forums.phpfreaks.com/topic/197872-null-date-in-mysql/#findComment-1038439 Share on other sites More sharing options...
kahodges Posted April 7, 2010 Author Share Posted April 7, 2010 Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/197872-null-date-in-mysql/#findComment-1038450 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.