BigQuery - Set date to April 1st based on current date
When you need to set start_date
to current financial year’s starting date.
2023-02-14
set to2022-04-01
2023-10-34
set to2023-04-01
DECLARE start_date DATE DEFAULT CURRENT_DATE();
SET start_date = DATE(
IF(
EXTRACT(MONTH FROM start_date) < 4,
EXTRACT(YEAR FROM start_date) - 1,
EXTRACT(YEAR FROM start_date)
),
4, 1
);
SELECT start_date AS month;
19. Apr 2023