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()
.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.