troubleshooting Question

SQL Syntax

Avatar of jknj72
jknj72 asked on
Microsoft SQL ServerSQL
6 Comments1 Solution140 ViewsLast Modified:
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' ) 

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!!

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros