I personally use the next code during my statement.

datediff(minute, visit.nexttime, visit.endtime)

the outcomes varies.

I'll show u a few results.

  • :24:26 - 25
  • :32:14 - 32
  • :05:12 - 5
  • :06:28 - 7
  • :03:52 - 4
  • :03:32 - 3

first one, 24 gathers to 25 while there's only 26 seconds.

second one, 32 remains where the second reason is 14.

third one, 5 remains 5, fair enough.

4th one, 6 gathers to 7 while you will find only 28 seconds.

fifth one, 3 gather to 4 coz of 52 seconds.

4g iphone, 3 remains 3 even there r 32 seconds.

Can you explain that?

I personally use the next code to obtain my first column.

CONVERT(varchar(6), datediff(second, visit.nexttime, visit.endtime)/3600)
+ ':' + 
RIGHT('0' + CONVERT(varchar(2), (datediff(second, visit.nexttime, visit.endtime) % 3600) / 60), 2)
+ ':' + 
RIGHT('0' + CONVERT(varchar(2), datediff(second, visit.nexttime, visit.endtime) % 60), 2) 
as 'Transaction Time'

Datediff is a little strange and rather nonintuitive. And delay pills work by doing this since old Sybase days.

Inside your situation datediff(m, x, y) completly ignores the seconds.

You will find the same issue whenever you attempt to calculate age range:

select datediff (y, '2010-12-31', '2011-01-01')

does't imply that the rounded difference is all about 12 months, it only states that 1 year happend.

To obtain the results you want, you have to go ahead and take difference in a more granular base, while you did using seconds.

I am not really acquainted with SQL Server, however reading through the documentation here i suspect i understand your reason for getting individuals results.

The return value is referred to because this:

Returns the count (signed integer) of the required datepart limitations entered between your specified startdate and enddate.

Because you specified minute for that datepart, I'd expect what this means is the seconds are overlooked also it just counts the number of occasions the moment changes between your startdate and enddate.


When the startdate and enddate were 50 seconds apart within the same minute, it might return .

When the startdate and enddate were only 5 seconds apart however in different minutes, it might return 1.

Please make reference to the MySql documentation. It will clarify this for you personally.