How many DATE data types are supported by MySQL?


MySQL supports following 5 types of DATE data type −

  • DATE - A date is in the range between 1000-01-01 and 9999-12-31. “YYYY-MM-DD” is the default DATE format. For example, January 17th, 1984 would be stored as 1984-01-17.
  • DATETIME − This data type supports a date along with time in the range between 1000-01-01 00:00:00 and 9999-12-31 23:59:59. “YYYY-MM-DD HH:MM:SS” is the default DATETIME format. For example, 2:20 in the afternoon on January 17th, 1984 would be stored as 1984-01-17 14:20:00.
  • TIMESTAMP − A timestamp data type supports a date along with time in the range between ‘1970-01-01 00:00:01’ to ‘2038-01-19 08:44:07’. It is just like the DATETIME data type. For example, 2:20 in the afternoon on January 17th, 1984 would be stored as 1984-01-17 14:20:00.
  • TIME − Stores the time in an HH:MM:SS format.
  •  YEAR(M) − Stores a year in a 2-digit or a 4-digit format. If the length is specified as 2 (for example YEAR(2)), YEAR can be between 1970 to 2069 (70 to 69). If the length is specified as 4, then YEAR can be 1901 to 2155. The default length is 4.

Updated on: 19-Jun-2020

86 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements