Murray’s company needed an easy way to tell whether or not a given date was a banking holiday or not. Someone wrote this function for MySQL .
CREATE FUNCTION `IS_HOLIDAY`(a_date datetime) RETURNS char(5) CHARSET utf8 COLLATE utf8_bin
READS SQL DATA
DETERMINISTIC
BEGIN
DECLARE is_holiday char(5);
select (CASE WHEN (DAYOFWEEK(a_date) = 1 OR DAYOFWEEK(a_date) = 7)
THEN 'Yes' ELSE 'No' END) INTO is_holiday;
RETURN is_holiday;
END
Murray apparently works for Ebenezer Scrooge, and should be grateful that he gets weekends off.
[Advertisement]
BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!