I have This function
ALTER FUNCTION [General].[GetWeekEnding]
(
@Date DATETIME
)
RETURNS DATETIME
AS
BEGIN
-- Return the result of the function
RETURN (DATEADD(day, -1 - (DATEPART(dw, @Date) + @@DATEFIRST - 2) % 7, @Date) + 7)
END
I need to also set the time to 00:00:00.000 as well as finding the week ending of a provided date any thoughts?
I use a UDF for adding time components to dates e.g.
Then in your case you can use it like this: