首页 > 代码库 > Sql获取当月月初和月末的时间

Sql获取当月月初和月末的时间

DECLARE @CurrentTime DATETIMEDECLARE @Start DATETIMEDECLARE @End DATETIMESET @CurrentTime = GETDATE()SET @Start = DATEADD(ms, -1, DATEADD(mm, DATEDIFF(m, 0, @CurrentTime), 0))SET @End = DATEADD(ms, -3, DATEADD(mm, DATEDIFF(m, 0, @CurrentTime) + 1, 0))PRINT @CurrentTimePRINT @StartPRINT @End

 

Sql获取当月月初和月末的时间