Advertisement
Google Ad Slot: content-top
MySQL Dates
MySQL Dates
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 Date Data Types
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 |
Create Table with Date and Time Columns
birth_date → Stores student’s date of birth.
admission_date → Automatically records current date and time.
graduation_year → Stores the year of graduation.