Reputation: 169
I am using DATEDIFF(MI,STARTDATE,ENDDATE)
I tried using MINUTE
and N
, but none of them are producing the expected result. Whenever the difference is 50 seconds, it is showing 1 minute.
I am using SQL Server 2008, and all the date times are in UTC format.
My Start Date is a database record and End Date is GETUTCDATE()
.
Upvotes: 1
Views: 450
Reputation: 21766
DATEDIFF
returns the count (signed integer) of the specified datepart boundaries crossed between the specified startdate and enddate. For example, this query will return 1
as a minute boundary has been crossed between the two times:
SELECT DATEDIFF(mi,'5 May 2015 11:59:00','5 May 2015 12:00:01')
You could use this statement instead:
SELECT DATEDIFF(s,DATEADD(s,-50,GETUTCDATE()),GETUTCDATE()) / 60
Upvotes: 4