开发者

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

开发者 https://www.devze.com 2023-04-12 12:31 出处:网络
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 o

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

精彩评论

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

关注公众号