I want to make a user defined function for calculating the month number from date. But the problem is that I have the months numbered as 1, 2, 3 ... and each month is of 26 days, that makes a total of 13 months in the year, rather than 12
any useful 开发者_如何学编程help?
I'm not going to ask you why you'd want to do this. But here we go:
select convert(int, (datepart(Dayofyear, @date)-1)/26.0)+1
精彩评论