CREATE FUNCTION GetWeekDayNameFromDate
(
  @Date datetime
)
RETURNS nvarchar(50)
BEGIN
DECLARE @DayName nvarchar(50)
SELECT
  @DayName =
  CASE (DATEPART(dw, @Date) + @@DATEFIRST) % 7
    WHEN 1 THEN ‘Sunday’
    WHEN 2 THEN ‘Monday’
    WHEN 3 THEN ‘Tuesday’
    WHEN 4 THEN ‘Wednesday’
    WHEN 5 THEN ‘Thursday’
    WHEN 6 THEN ‘Friday’
    WHEN 0 THEN ‘Saturday’
  END
RETURN @DayName
END
GO