Get the upper and lower boundaries of the current day and the current month

DECLARE @StatisticsDay DATE
SET @StatisticsDay=GETDATE()

DECLARE @StatisticsTodayStartTime DATETIME
DECLARE @StatisticsTodayEndTime DATETIME
DECLARE @StatisticsMonthStartTime DATETIME
DECLARE @StatisticsMonthEndTime DATETIME

SET @StatisticsTodayStartTime=@StatisticsDay
SET @StatisticsTodayEndTime=DATEADD(DD, 1, @StatisticsDay)
SET @StatisticsMonthStartTime=DATEADD(MM, DATEDIFF(MM, 0, @StatisticsDay), 0)
SET @StatisticsMonthEndTime=DATEADD(MM, DATEDIFF(MM, 0, @StatisticsDay) + 1, 0)

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324767484&siteId=291194637