Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 new question

Author  Topic 

Trininole
Yak Posting Veteran

83 Posts

Posted - 2010-05-12 : 14:53:52
how would i Write a syntax that runs if today is Thursday and does not run if today is not Thursday??

Roger DeFour

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-05-12 : 14:57:37
quote:
Originally posted by webfred


if datename(dw, getdate()) <> 'Thursday'
begin
print 'no work today'
end
else
begin
print 'here we go'
end



No, you're never too old to Yak'n'Roll if you're too young to die.




No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Trininole
Yak Posting Veteran

83 Posts

Posted - 2010-05-12 : 14:59:31
Thank you

Roger DeFour
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-05-12 : 15:01:18
welcome


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-05-12 : 15:12:54
But consider regional settings.
In Germany the used statement would return 'Donnerstag' instead of 'Thursday'.
You can avoid this by using for example
set language english
in front of your statement.

Have a look at
select DATEPART (dw, getdate())
it returns the number of the day.
today it returns 4.

Also it depends on the setting of DATEFIRST:
http://msdn.microsoft.com/en-us/library/ms181598.aspx


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -