开发者

how to make a UDF in sql for determining month of year?

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜