MySQL Dates

Date handling.

MySQL Date and Time Types

The most difficult part when working with dates is to be sure that the format of the date you are trying to insert, matches the format of the date column in the database.

MySQL comes with the following data types for storing a date or a date/time value in the database:

  • DATE - format YYYY-MM-DD
  • DATETIME - format: YYYY-MM-DD HH:MI:SS
  • TIMESTAMP - format: YYYY-MM-DD HH:MI:SS
  • YEAR - format YYYY or YY

Example

SELECT * FROM Orders WHERE OrderDate='2008-11-11';