Thursday, December 3, 2015

MsSQL - Getting current week number

To calculate the week number, there is no straight function in MsSQL and we need to do some calculation. And here is how it can be taken easily

 select (DATEPART(dy,DATEDIFF(dd,0,getdate())/7*7+3)+6)/7 as 'WeekNumber'   

And the result is;


Thanks for reading... :)

No comments:

Post a Comment