Skip to content

YEAR_MONTH

SELECT EXTRACT(YEAR_MONTH FROM '2021-05-27 01:23:45') as ExtractedYearMonth;
+-------------------+
| ExtractedYearMonth|
+-------------------+
| 202105|
+-------------------+

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.