YEAR_MONTH
YEAR_MONTH is a type of data in SQL that allows storing of the year and month only, not including information about the day or time. This data type is particularly useful for grouping and reporting purposes where the specific day or time is not a major concern.
Example
Output
Explanation
The EXTRACT
function with YEAR_MONTH
is used to retrieve the year and month as a decimal format (YYYYMM) from a specified date. Here, ‘2021-05-27 01:23:45’ was provided as the date, which returned ‘202105’ as the output.