Sql server gestire le settimane

select   cast(CONVERT(char(10), getdate(), 110) as datetime) [today]

,        datename(dw, getdate()) [day]

,        datepart(dw, getdate()-1) [day of week]

,        datepart(dw, getdate()-1)-1 [days since monday]

,        7-datepart(dw, getdate()-1) [days until sunday]

,        cast(CONVERT(char(10), (getdate()-(datepart(dw, getdate()-1)-1)), 110) as datetime) [monday]

,        cast(CONVERT(char(10), (getdate()+(7-datepart(dw, getdate()-1))), 110) as datetime) [sunday]

 

query utile quando si devono trattare le settimane...

posted @ martedì 1 luglio 2008 07:03

Print
«novembre»
domlunmarmergiovensab
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567