Datediff With Minute Does Not Return Expected Value
Say, I have the following SQL Server 2008 table with data: CREATE TABLE tbl (dtIn DATETIME2, dtOut DATETIME2) INSERT tbl VALUES ('9/10/2012 5:14:10 AM', '9/10/2012 5:15:09 AM'), ('
Solution 1:
The return value of each is measuring different things.
It would be prudent to pay attention to the DATEDIFF docs here:
Returns the count (signed integer) of the specified datepart boundaries crossed between the specified startdate and enddate.
which leads to the following 2 second interval:
SELECT datediff(minute, '9/10/2012 5:14:59 AM', '9/10/2012 5:15:01 AM')
returning 1 because it crosses a minute boundary. I suspect that you did not take this behaviour into account.
Post a Comment for "Datediff With Minute Does Not Return Expected Value"