Is it better to use 0 or NULL as the default for MySQL INT fields that store dates?
I need to live with INTs in our date / time records in MySQL, so I'm trying to figure out if it's better to use 0 or NULL as the default for these fields. We migrate and the data comes in as 0000-00-00 00:00:00, Unix timestamp, 0, NULL, false, etc, so I convert everything via PHP strtotime () and date () functions, but getting strange results when pasting.
I may end up with something useful in PHP, but I'm not sure after what is better to use as the default in MySQL.
source to share
I found that using NULL prevents dates or int from being "less than this" because MySQL does not compare ints and nulls in this context. When I set them to 0 by default, they came up with a selection and that was what we wanted. I'm not sure what complications this will cause in the future (we may have to find an alternative solution), but right now it is getting the data we need.
source to share