Sql Server
Posted easy5
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Sql Server相关的知识,希望对你有一定的参考价值。
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的主要内容,如果未能解决你的问题,请参考以下文章