2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`lastDayOfWeek`(vYear INT, vWeek INT)
|
2024-01-15 11:31:03 +00:00
|
|
|
RETURNS date
|
|
|
|
DETERMINISTIC
|
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* Returns the date of the last day of the week
|
|
|
|
*
|
|
|
|
* @param vYear The year
|
|
|
|
* @param vWeek The week number
|
|
|
|
* @return Date of the first day of the week
|
|
|
|
*/
|
|
|
|
DECLARE vDate DATE;
|
|
|
|
|
|
|
|
SELECT dated INTO vDate
|
|
|
|
FROM `time`
|
|
|
|
WHERE `year` = vYear
|
|
|
|
AND `week` = vWeek
|
|
|
|
ORDER BY dated DESC
|
|
|
|
LIMIT 1;
|
|
|
|
|
|
|
|
RETURN vDate;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|