码迷,mamicode.com
首页 > 其他好文 > 详细

根据年月得到当月的天数

时间:2017-01-03 15:21:04      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:style   软件测试   arm   int   函数   soft   base   sha   returns   

Go

--创建函数

create function [dbo].[get_days]

(

    @yearmonth varchar(6) --参数格式:

)

returns int

as

begin

    return (datediff(d,@yearmonth+‘01‘,dateadd(mm,1,@yearmonth+‘01‘)))

end

 

--测试示例

select dbo.[get_days](‘201103‘)

 

--运行结果

/*

31

*/

 
 

根据年月得到当月的天数

标签:style   软件测试   arm   int   函数   soft   base   sha   returns   

原文地址:http://www.cnblogs.com/accumulater/p/6244681.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!