There are several different ways to store dates and times in MySQL, and knowing which one to use requires understanding what you'll be storing and how MySQL handles each type.
There are five column types that you can use to store temporal data in MySQL. They are:
-
DATE -
DATETIME -
TIMESTAMP -
YEAR -
TIME
Each column type stores slightly different data, has different minimum and maximum values, and requires different amounts of storage.
In the table below, you'll see each column type and their various attributes.
| Column | Data | Bytes | Min | Max |
|-----------|-------------|-------|---------------------|---------------------|
| DATE | Date only | 3 | 1000-01-01 | 9999-12-31 |
| DATETIME …[Read more]