I'm trying to do some DateTime logic in SQL:
SET @DayEnd = DATEADD(MILLISECOND, -1, @BeginNextDay)
If, for instance, @BeginNextDay is '2019-02-04 00:00:00.000' and I'm performing the code above, I would expect @DayEnd to be '2019-02-03 29:59:59:999'. Unfortunately this isn't the case, the result is '2019-02-04 00:00:00.000'.
When I'm subtracting 12 milliseconds, the result is '2019-02-03 23:59:59.987'.
When I'm substracting 10 milliseconds, the result is '2019-02-03 23:59:59.990' as expected.
Can somebody explain to me what SQL is doing that gives me this (for me) unexpected result?