SQL Server 取前一天的0点和23点59分59秒

1 DECLARE @startDate1 DATE;
2 DECLARE @startDate DATETIME;
3 SET @startDate1=GETDATE();SELECT @startDate=DATEADD(DAY,-1,@startDate1); 
4 DECLARE @endDate DATETIME ;SET @endDate=DATEADD(second,-1,CONVERT(DATETIME,@startDate1)); 
5 SELECT @startDate startDate,@endDate endDate;
6 
7 startDate               endDate
8 ----------------------- -----------------------
9 2014-05-19 00:00:00.000 2014-05-19 23:59:59.000

 

posted on 2014-05-20 14:14  东云180  阅读(2092)  评论(0编辑  收藏  举报

导航