15.6.8-sql小技巧
时间:2021-07-01 10:21:17
帮助过:5人阅读
@someDay datetime,
@firstDay datetime,
@endDay datetime
set @someDay=‘2015.2.2‘
set @firstDay=dateadd(
month,
datediff(
month,
0,
@someDay),
0)
set @endDay=dateadd(
month,
datediff(
month,
-1,
@someDay),
-1)
select @someDay,
@firstDay,
@endDay
亮点在这里:
declare @someDay datetime, @someDay2 datetime
set @someDay =0
set @someDay2=-1
select @someDay,@someDay2
返回:
15.6.8-sql小技巧
标签: