25 lines
480 B
SQL
25 lines
480 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`lastDayOfWeek`(vYear INT, vWeek INT)
|
|
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 ;
|