我设置了一个存储过程,以便获得今天的结果
所以
DECLARE @Start DATETIME
DECLARE @End DATETIME
SET @Start = DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), 0)
SET @End = DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), 1)
PRINT @Start
PRINT @End
给了我时间段
May 30 2016 12:00AM
May 31 2016 12:00AM
如何修改条款以给我一段时间
May 29 2016 5:30PM(Previous day)
May 31 2016 12:00AM(Today)
亲切的问候
答案 0 :(得分:1)
试试这个解决方案:
SET @Start = DATEADD(MINUTE, 30, DATEADD(HOUR, 17, DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), -1)))
SET @End = DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), 1)
答案 1 :(得分:1)
DECLARE @Start DATETIME
DECLARE @End DATETIME
SET @Start = GETDATE()-1
SET @End = DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), 1)
PRINT @Start
PRINT @End
答案 2 :(得分:1)
dateadd(day, -1, getdate())
可能只是使用上面的DateAdd。