Categories
Database MySQL

Incomplete Dates in MySQL

Sometimes you can't store the year portion of a date in MySQL because it's not available, such as when people are willing to provide their birthday but not the year of birth.

You can resolve this by entering "0000" in MySQL, but that won't work will all databases.

Another solution is to provide the year 1200 as a placeholder for those dates.

Using the year 1200 works because it it a leap year, so date formatting and calculations that are sensitive to leap years will work, but you'll have to filter out the year for certain queries and calculations.