Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 datediff issue

Author  Topic 

chapm4
Yak Posting Veteran

58 Posts

Posted - 2012-04-02 : 12:13:17
Need to return number of day's since incident but anything before 7am the following day is yesterdays number. I know it doesn't make sense...I will try to explain.


DATEDIFF("d",eveEventDate,GETDATE())


Currently returns 206 since the last incident date is 2011-09-09. I need it to return 205 if it is before 7:00am tomorrow. Time is on 24hr.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-04-02 : 12:31:55
DATEDIFF(DAY, eveEventDate, DATEADD(HOUR, -7, GETDATE()))



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -