首页 > 数据库技术 > 详细

Sql Server

时间:2017-12-08 13:21:13      阅读:239      评论:0      收藏:0      [点我收藏+]

 

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

原文:http://www.cnblogs.com/easy5weikai/p/8004819.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!