CREATE OR REPLACE FUNCTION TEST.CONVERT_UTC_TO_NZ (INTS TIMESTAMP) RETURNS TIMESTAMP LANGUAGE SQL DETERMINISTIC BEGIN declare vHoursToAdd INT; if INTS IS NULL then set vHoursToAdd = NULL; else if INTS < timestamp('2014-09-27 14:00:00') OR (INTS >= timestamp('2015-04-04 14:00:00') and INTS < timestamp('2015-09-26 14:00:00') ) OR (INTS >= timestamp('2016-04-02 14:00:00') and INTS < timestamp('2016-09-24 14:00:00') ) OR (INTS >= timestamp('2017-04-01 14:00:00') and INTS < timestamp('2017-09-23 14:00:00') ) OR (INTS >= timestamp('2018-03-31 14:00:00') and INTS < timestamp('2018-09-29 14:00:00') ) OR (INTS >= timestamp('2019-04-06 14:00:00') and INTS < timestamp('2019-09-28 14:00:00') ) OR (INTS >= timestamp('2020-04-04 14:00:00') and INTS < timestamp('2020-09-26 14:00:00') ) then set vHoursToAdd = 12; else set vHoursToAdd = 13; end if; end if; RETURN INTS + vHoursToAdd HOURS; END@