CREATE FUNCTION Last_Week_Day (@date AS datetime) RETURNS datetime AS BEGIN return DATEADD(DAY, 6-DatePart(DW, @date), @date) END