DECLARE @TheDate DATETIME, @HalfDayAndaBit DECIMAL (14,13)
SET @HalfDayAndaBit = 0.5000000385803
SET @TheDate = '2008-02-05 11:59:59.993'
SELECT @TheDate
SELECT CAST(@TheDate-@HalfDayAndaBit AS INT)
SELECT CAST(CAST(@TheDate-@HalfDayAndaBit AS INT) AS DATETIME)
SET @TheDate = '2008-02-05 11:59:59.997'
SELECT @TheDate
SELECT CAST(@TheDate-@HalfDayAndaBit AS INT)
SELECT CAST(CAST(@TheDate-@HalfDayAndaBit AS INT) AS DATETIME)
That's where the 'AndaBit' comes in.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden