sql get first date of the week and last day of the week max $15

Job ID: 31918276

Budget: $10 – $30 USD

i have this function that give last date of the week given a date and first date of week

some it work sometime it does not

CREATE FUNCTION [dbo].[fnGetLastDateOfWeek]
(
@CurrentDate AS DATE
)
RETURNS DATE
AS
BEGIN

RETURN DATEADD(DAY, 8 - DATEPART(WEEKDAY, GETDATE()), CAST(@CurrentDate AS DATE))

END

CREATE FUNCTION [dbo].[fnGetFirstDateOfWeek]
(
@CurrentDate AS DATE
)
RETURNS DATE
AS
BEGIN

RETURN DATEADD(week, DATEDIFF(week, 0, @CurrentDate), 0)

END