I am expecting this to return the value of ‘C’, but it is returning ‘A’. I cannot seem to figure out why this will not work as my logic looks sound.
DECLARE @WeekStartDay varchar(10)
DECLARE @WeekEndDay varchar(10)
SET @WeekStartDay = 'Saturday'
SET @WeekEndDay = 'Saturday'
SELECT
CASE
WHEN (
((@WeekStartDay = 'Saturday') OR (@WeekStartDay = 'Sunday'))
AND
((@WeekEndDay <> 'Saturday') OR (@WeekEndDay <> 'Sunday'))
)
THEN 'A'
WHEN (
((@WeekEndDay = 'Saturday') OR (@WeekEndDay = 'Sunday'))
AND
((@WeekStartDay <> 'Saturday') OR (@WeekStartDay <> 'Sunday'))
)
THEN 'B'
WHEN (
((@WeekEndDay = 'Saturday') OR (@WeekEndDay = 'Sunday'))
AND
((@WeekStartDay = 'Saturday') OR (@WeekStartDay = 'Sunday'))
)
THEN 'C'
END AS Result
My intended function is:
I am trying to get it to deteremine
IF the @WeekStartDay = Saturday or Sunday AND @WeekEndDay IS NOT Saturday or Sunday THEN ‘A’
IF the @WeekEndDay = Saturday or Sunday AND @WeekStartDay IS NOT Saturday or Sunday THEN ‘B’
IF @WeekStartDay AND @WeekEndDay BOTH = Saturday or Sunday THEN ‘C’
Hmmm from responses looks like my logic was way more off than I thought.
Substituting the parameter values in as literals gives (for the first case)
Which is
Which is
Which is
I think you need