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

 

转载于:https://www.cnblogs.com/cyun/p/5565474.html

你可能感兴趣的:(SQL Server 取前一天的0点和23点59分59秒)