Question about Date and NULL

I’m using phpMyAdmin for a simple mySQL database. Am a bit confused here, as I have two date fields which as far as I can tell are the same - i.e. Date, with a default of NULL, with NULL ticked.

If I update a record, but leave both of those fields blank, one stays blank, and the other gets populated with 0000-00-00 (and displays 30 November -0001 on the website.)

Any pointers on why two supposedly identical fields are behaving differently?


for starters, those columns aren’t identical – one allows NULL, the other doesn’t

what happens when you “leave both of those fields blank” is this –

since the NOT NULL column doesn’t allow a null, mysql, in its infinite wisdom, instead of rejecting the insert with an error message, decides that it will try to insert a non-null value, and substitutes the “zero” value, which in the case of a DATE column is “0000-00-00” (even though this isn’t a valid date by normal standards, mysql allows it)

not sure how you get 30 November -0001 from 0000-00-00, though

They were set up identically in phpMyAdmin, i.e. both set to allow NULL there.

I have resolved it though - the issue was the syntax in the update script where I had to change a ’ ’ to a NULL and a LIKE to an =.