Avatar of jknj72

asked on 

SQL Syntax

I have a param I pass in that is a number representation of the day of Week. It will be either 1 - 5 for Mon - Friday

Its in my Where clause so I am trying to set it to the day of week

heres what I got....

and DATENAME(weekday, wid.WorkDate) = 
(CASE WHEN @WeekDay = 1 THEN 'Monday'  
OR CASE WHEN @WeekDay = 2 THEN 'Tuesday'  
OR CASE WHEN @WeekDay = 3 THEN 'Wednesday'  
OR CASE WHEN @WeekDay = 4 THEN 'Thursday'  
OR CASE WHEN @WeekDay = 5 THEN 'Friday' ) 

Open in new window

I know I can declare a variable and set the day that way but I would like to figure out how to do it this way!!

Microsoft SQL ServerSQL

Avatar of undefined
Last Comment

8/22/2022 - Mon