DECLARE @CurrentDate DATETIME=GETDATE();
select
DATEADD(dd,0, DATEDIFF(dd,0,@CurrentDate)) AS 当前日期,
DATEADD(dd,-1, DATEDIFF(dd,0,@CurrentDate)) AS 昨天,
DATEADD(MM,DATEDIFF(MM,0,@CurrentDate),0) AS 本月第一日,
DATEADD(DAY,-1,DATEADD(MM,DATEDIFF(MM,0,@CurrentDate)+1,0)) 本月最后一日,
DATEADD(mm,DATEDIFF(mm,0,dateadd(month,-1,@CurrentDate)),0) AS 上月第一日,
dateadd(d,-1,dateadd(m,-1,DATEADD(mm, DATEDIFF(m,0,@CurrentDate)+1, 0))) AS 上月最后一日
时间: 2024-10-10 21:41:53