Date Type
Overview
The DATE
data type is used to store and insert date values.
Structure
The date type contains three components: year, month, and day. It’s represented in a 32-bit integer. Here is the breakdown:
-
Day component: 5 bits store the number of days within a month. Its value is in the range
<1, 31>
. -
Month component: 4 bits store the month of the year. Its value is in the range
<1, 12>
. -
Year component: 23 bits store the number of years. Its value is from range
<0, 2^23 - 1>
.
Format
-
YYYY
- Four-digit year -
MM
- One / two-digit month -
DD
- One / two-digit day
Example
In this example, we will create an emp_submission table that consists of the candidate ID, candidate name, the submitted department, and a submission date with a DATE
data type.
Now that the data has been inserted, let’s execute the SELECT
statement below:
The following is the result of the SELECT
statement where the values in the sub_date
column have DATE
data type: