SELECT
my_date + (
CASE
WHEN
my_date BETWEEN
next_day(to_date( extract(YEAR FROM my_date)||'0324','YYYYMMDD'), 'Sunday')
AND
next_day(to_date( extract(YEAR FROM my_date)||'1024','YYYYMMDD'), 'Sunday')
THEN
2
ELSE
1
END
)/24
FROM
my_table;
Looking at that, the next step I'd suggest is to either factor the entire CASE or just the next_day parts of it out into a function that is called, rather than leaving it all inline like that.
Factoring out the CASE would leave you with something like
SELECT
my_date + (find_dst_offset(my_date))/24
FROM
my_table;
|