| Author |
Topic |
|
Wilmos
Starting Member
13 Posts |
Posted - 2009-11-09 : 14:40:59
|
| Hi all prof in the world,I would like to write a stored procudure to perform different task according to different day.LEt say for example, from Monday-Friday, I wish to trigger sp 1, Saturday, sp2 and Sunday sp3.Is it possible to do that?Many thanks in adv. |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-11-09 : 14:48:18
|
Look at the result from:select datename(weekday,getdate()) No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Wilmos
Starting Member
13 Posts |
Posted - 2009-11-09 : 14:51:34
|
| wow!!!! Many thanks to webfred for your prompt and prof advice!It works !! Many thanks. :-) |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-11-09 : 14:52:33
|
Datename is locale dependant.Consider thisDATEDIFF(DAY, 0, GETDATE()) % 7 / 5 N 56°04'39.26"E 12°55'05.63" |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-11-09 : 14:53:06
|
welcome  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Wilmos
Starting Member
13 Posts |
Posted - 2009-11-09 : 14:57:42
|
| Hi Peso,May i know wht is the locale dependant meant?Many thanks! |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-11-09 : 15:04:52
|
See this:set language germanselect datename(weekday,getdate())set language englishselect datename(weekday,getdate()) No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Wilmos
Starting Member
13 Posts |
Posted - 2009-11-09 : 15:08:22
|
| wowow!! thank webfred again for your prompt, short but clear and powerful explanation!thanks. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2009-11-11 : 13:31:57
|
I assume that checking the date by language is sufficient for your needs. But, you could always use the DATEPART function in conjuction with the @@DATEFIRST function: SET LANGUAGE Italian;GOSELECT @@DATEFIRST, DATEPART(DW, GETDATE());GOSET LANGUAGE us_english;GOSELECT @@DATEFIRST, DATEPART(DW, GETDATE()); |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2009-11-11 : 14:52:07
|
| [code]-- Returns 0=Mon, 1=Tue, 2=Wed, 3=Thu, 4=Fri, 5=Sat, 6=Sunselect datediff(day,0,getdate())%7[/code]CODO ERGO SUM |
 |
|
|
|