0
|
北纬六十六度Lv4初级互助发布于2021-11-15 16:30(编辑于 2021-11-15 16:44)
|
day(dateadd(month,1,getdate()) - day(getdate())) 获取当前月天数 更换getdate()的日期值,就可以求其他月份的
|
-
yzm189640(提问者)
- 我想求的是今年每个月的天数
-
北纬六十六度 回复 yzm189640(提问者)
-
select day(dateadd(month,1,\'20210101\') - day(\'20210101\')) as 一月份天数,
day(dateadd(month,1,\'20210201\') - day(\'20210201\')) as 二月份天数,
day(dateadd(month,1,\'20210301\') - day(\'20210301\')) as 三月份天数,
day(dateadd(month,1,\'20210401\') - day(\'20210401\')) as 四月份天数,
day(dateadd(month,1,\'20210501\') - day(\'20210501\')) as 五月份天数,
day(dateadd(month,1,\'20210601\') - day(\'20210601\')) as 六月份天数,
day(dateadd(month,1,\'20210701\') - day(\'20210701\')) as 七月份天数,
day(dateadd(month,1,\'20210801\') - day(\'20210801\')) as 八月份天数,
day(dateadd(month,1,\'20210901\') - day(\'20210901\')) as 九月份天数,
day(dateadd(month,1,\'20211001\') - day(\'20211001\')) as 十月份天数,
day(dateadd(month,1,\'20211101\') - day(\'20211101\')) as 十一月份天数,
day(dateadd(month,1,\'20211201\') - day(\'20211201\')) as 十二月份天数
这样行了不
|
|