First using CURRENT_TIMESTAMP
and EXTRACT
to get today’s date and month. Then use a CASE
statement on MONTH
to figure out the quarter:
WITH quarters AS (
SELECT EXTRACT( MONTH FROM CURRENT_TIMESTAMP ) AS MONTH
) SELECT CURRENT_TIMESTAMP as Today,
CASE
WHEN 1 <= MONTH AND MONTH <= 3 THEN 'Q1'
WHEN 4 <= MONTH AND MONTH <= 6 THEN 'Q2'
WHEN 7 <= MONTH AND MONTH <= 9 THEN 'Q3'
ELSE 'Q4'
END AS Quarters
FROM quarters
;