时间:2021-07-01 10:21:17 帮助过:6人阅读
declare @ctrBeginTime =null;
if(@ctrBeginTime Is NUll)
begin
set @ctrBeginTime= GETDATE();
end
declare @statisticsDate as datetime = CONVERT(varchar(10),@ctrBeginTime,120); /*统计时间*/
declare @ThisYear1stDay as datetime = DATEADD(yy, DATEDIFF(yy,0,@statisticsDate),0); /*本年的第一天*/
declare @LastYearLastDay as datetime = DATEADD(dd,-1,@ThisYear1stDay); /*去年的最后一天*/
declare @LastYear1stDay as datetime = DATEADD(yy, DATEDIFF(yy,0,@LastYearLastDay),0); /*去年的第一天*/
declare @LastYearMaxStatsDate as datetime = @LastYearLastDay;/*去年的最后一次统计时间*/
Sql Server
标签:sql tis get max statsd sda time arch char