0
0
MySQLquery~5 mins

Date and time types in MySQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the DATE data type in MySQL?
The DATE data type stores date values in the format 'YYYY-MM-DD', representing year, month, and day without time information.
Click to reveal answer
intermediate
How does the DATETIME type differ from the TIMESTAMP type in MySQL?
DATETIME stores date and time without timezone conversion, while TIMESTAMP stores date and time as UTC and converts to the current timezone on retrieval.
Click to reveal answer
beginner
What is the format of the TIME data type in MySQL?
TIME stores time values in the format 'HH:MM:SS', representing hours, minutes, and seconds.
Click to reveal answer
intermediate
Which MySQL date/time type would you use to store only the year and month?
MySQL does not have a specific type for only year and month; you can use DATE and ignore the day or store as a string.
Click to reveal answer
intermediate
What happens if you insert an invalid date like '2024-02-30' into a DATE column in MySQL?
MySQL will reject the invalid date or store '0000-00-00' depending on SQL mode settings, because '2024-02-30' is not a valid calendar date.
Click to reveal answer
Which MySQL data type stores both date and time without timezone conversion?
ATIME
BDATE
CDATETIME
DTIMESTAMP
What is the default format for the TIME data type in MySQL?
AMM-DD-YYYY
BYYYY-MM-DD
CYYYY-MM-DD HH:MM:SS
DHH:MM:SS
Which MySQL data type automatically converts stored time to UTC and back to local time on retrieval?
ATIMESTAMP
BTIME
CDATE
DDATETIME
If you want to store only a date without time, which MySQL type should you use?
ADATE
BTIME
CDATETIME
DTIMESTAMP
What will MySQL do if you insert '2024-02-30' into a DATE column with strict mode enabled?
AStore '0000-00-00'
BReject the insert with an error
CStore '2024-02-30' as is
DAutomatically correct to '2024-02-29'
Explain the differences between DATE, DATETIME, and TIMESTAMP types in MySQL.
Think about what each type stores and how timezones are handled.
You got /3 concepts.
    Describe how MySQL handles invalid dates when inserting into a DATE column.
    Consider SQL mode settings and validation rules.
    You got /3 concepts.