MySQL Tutorial
In MySQL, date and time data are handled using specific data types and functions. Dates are commonly used in applications for storing events, records, transactions, and other time-based data.
MySQL comes with the following data types for storing a date or a date/time value in the database:
Data Type |
Description |
Format |
---|---|---|
DATE |
Stores date (without time) |
YYYY-MM-DD |
DATETIME |
Stores date and time |
YYYY-MM-DD HH:MM:SS |
TIMESTAMP |
Similar to |
YYYY-MM-DD HH:MM:SS |
TIME |
Stores time (without date) |
|
YEAR |
Stores only the year |
YYYY |
birth_date
→ Stores student’s date of birth.
admission_date
→ Automatically records current date and time.
graduation_year
→ Stores the year of graduation.