Date Time Data types in MySQL

Notes:

MySQL Date Time Data Types: date and time

date:
- stores date in yyyy-mm-dd format

time:
- stores time in hh:mm:ss format

datetime:
- stores date and time in yyyy-mm-dd hh:mm:ss format
- if you want to store and retrieve date and time same or as it is; regardless of local time zone use datetime data type

timestamp:
- stores date and time in yyyy-mm-dd hh:mm:ss format with respect to universal time
- while retrieving it converts the date and time with respect to local time zone and returns
- if you want to retrieve the date and time with respect to local time zone use timestamp data type

year:
- stores year in yyyy format

Interview Questions: