# YEAR Type

The YEAR type is a 1-byte type used to represent the year value. Can be declared as YEAR with an implicit display width of 4 characters or equivalently as `YEAR(4)`, explicitly specifying the display width of 4.

MatrixOne displays YEAR values in YYYY format, ranging from 0001 to 9999.

YEAR accepts input values in various formats:

- As a 4-bit string with a range between '0001' and '9999'.
- As a 4-digit number with a range of 0001 to 9999.
- As a 1-bit or 2-bit string with a range between '0' and '99'. MatrixOne converts values ranging from '0' to '00' to YEAR values, automatically completing the first two digits '00', i.e. '0000' ~ '0099'.
- As a result of a function that returns acceptable values in the YEAR context, such as `NOW()`.

## Double-digit years in date

Because the double-digit years in a date lack century values, its meaning is not clear enough. For consistency of internal storage, MatrixOne must interpret these date values as 4-digit forms.

For DATETIME, DATE, and TIMESTAMP types, MatrixOne follows the following rules to explain dates with uncertain year values:

- The year value within range 00-99 becomes 0000-0099.

Here are examples of dates involving 2 digits:

1. Explain the date of type DATETIME:

Suppose we have a column of type DATETIME named `event_date` with the following date values:

| event_date |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| 2023-07-12 08:30 |
| 99-01-15 13:45 |
| 23-05-06 09:00 |

According to the rule, 2 years in the date value are interpreted as:

- 99-01-15 is interpreted as January 15, 0099.
- 23-05-06 is interpreted as May 6, 0023.

2. Explain the date of the DATE type:

Suppose we have a column of type DATE named `birth_date` with the following date values:

| birth_date |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| 95-08-21 |
| 04-11-30 |
| 88-03-17 |

According to the rule, 2 years in the date value are interpreted as:

- 95-08-21 is interpreted as August 21, 0095.
- 04-11-30 is interpreted as November 30, 0004.
- 88-03-17 is interpreted as March 17, 0088.

3. Explain the date of YEAR type:

Suppose we have a column of type YEAR called `graduation_year` with the following year values:

| graduation_year |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| 65 |
| 78 |
| 03 |

According to the rule, 2 years in the year value are interpreted as:

- 65 is interpreted as 0065.
- 78 is interpreted as 0078.
- 03 is interpreted as 0003.
