最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
查询季度初末,年上下个季度初末sql语句
时间:2022-11-14 23:38:20 编辑:袖梨 来源:一聚教程网
查询季度初末,年上下个季度初末sql语句
declare @date datetime
set @date=getdate()
--季度初,计算给定日期所在季度的第一天
select dateadd(quarter,datediff(quarter,0,@date),0) as '当前季度的第一天'
--季度末,计算给定日期所在季度的最后一天
select dateadd(quarter,1+datediff(quarter,0,@date),-1) as '当前季度的最后一天'
--上个季度初
select dateadd(quarter,datediff(quarter,0,@date)-1,0) as '当前季度的上个季度初'
--上个季度末
select dateadd(quarter,datediff(quarter,0,@date),-1) as '当前季度的上个季度末'
--下个季度初
select dateadd(quarter,1+datediff(quarter,0,@date),0) as '当前季度的下个季度初'
--下个季度末
select dateadd(quarter,2+datediff(quarter,0,@date),-1) as '当前季度的下个季度末'
go