If select datename(dw,getdate(@SelectedDate)) is Sunday

@SelectedDate is an actual date like 04/26/2006

I don't know if I'm doing this line right
select datename(dw,getdate(@SelectedDate))
but

I want to say if select datename(dw,getdate(@SelectedDate))  is Sunday then
    First = 1

if Monday then
    First = 2

etc.

How do I do that?

****************************

IF @FreqID = 4
BEGIN
UPDATE SusansTable
     SET
         FreqID = @FreqID,
         StartDate = 01/01/1900,
         First = 2
         
WHERE SomeID = @SomeID
END
LVL 1
net_susanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Aneesh RetnakaranDatabase AdministratorCommented:
Hi net_susan,
IF @FreqID = 4
BEGIN
UPDATE SusansTable
     SET
         FreqID = @FreqID,
         StartDate = 01/01/1900,
         [First] = CASE datename(dw,getdate()) WHEN 'Sunday' then 1
            WHEN 'Monday' then 2
            WHEN 'Tuesday' then 3
            WHEN 'Wednesday' then 4
            WHEN 'Thursday' then 5
            WHEN 'Friday' then 6
            ELSE 7 End
                     
WHERE SomeID = @SomeID
END



select datename(dw,getdate())

Aneesh R!
0
Aneesh RetnakaranDatabase AdministratorCommented:
You can rplace GETDATE() with @selecteddate


IF @FreqID = 4
BEGIN
UPDATE SusansTable
     SET
         FreqID = @FreqID,
         StartDate = 01/01/1900,
         [First] = CASE datename(dw,@selectedDate) WHEN 'Sunday' then 1
            WHEN 'Monday' then 2
            WHEN 'Tuesday' then 3
            WHEN 'Wednesday' then 4
            WHEN 'Thursday' then 5
            WHEN 'Friday' then 6
            ELSE 7 End
                     
WHERE SomeID = @SomeID
END



0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MacNuttinCommented:
Here's some ideas:

DECLARE @DAY varchar(10), @SelectedDate datetime
SET @SelectedDate = getdate()
print @SelectedDate
SET @DAY = (select datename(dw,@SelectedDate))
print @Day
SET @DAY = (select datename(dd,@SelectedDate))
print @Day
0
net_susanAuthor Commented:
Thank you!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.