About 314,000 results
Open links in new tab
  1. Calculate time difference in minutes in SQL Server

    Nov 18, 2014 · I need the time difference between two times in minutes. I am having the start time and end time as shown below: start time | End Time 11:15:00 | 13:15:00 10:45:00 | 18:59:00 I need the output for first row as 45,60,15 which corresponds to the time difference between 11:15 and 12:00, 12:00 and 13:00, 13:00 and 13:15 respectively.

  2. Difference of two date time in sql server - Stack Overflow

    Jan 22, 2010 · Is there any way to take the difference between two datetime in sql server? For example, my dates are 2010-01-22 15:29:55.090 2010-01-22 15:30:09.153 So, the result should be 14.063 seconds.

  3. Time difference with hours, minutes and seconds in SQL Server

    May 10, 2016 · Note: As TT rightfully wrote in his comment, casting to time will only work if the difference between @EndTime and @StartTime is less then 24 hours. If you need to compare times that are further apart, you need to use one of the other solutions suggested.

  4. sql server - Calculate Time Difference Between Two Rows - Stack …

    Before I set the data to be collected every 10 seconds it was collected whenever the Value changed. There aren't any duplicate entries in terms of time, the minimum time difference is 1 second. How can I set up a query to get the elapsed time between rows for the case when I don't know the time interval between readings? I am using SQL Server 2005.

  5. How to calculate time difference in T-SQL - Stack Overflow

    Jul 26, 2015 · I have created a table with columns of datatype time(7) I want to calculate the time difference between them. Table time: id timefrom timeto result ----- 1 13:50:00 14:10:00 00:20:00 2 11:10:00 11:00:00 23:50:00 For example: Time From 13:50; Time To 14:10

  6. t sql - How to calculate difference in hours (decimal) between two ...

    I have to calculate the difference in hours (decimal type) between two dates in SQL Server 2008. I couldn't find any useful technique to convert datetime to decimal with 'CONVERT' on MSDN. Can anybody help me with that? UPDATE: To be clear, I need the fractional part as well (thus decimal type). So from 9:00 to 10:30 it should return me 1.5.

  7. SQL time difference between two dates result in hh:mm:ss

    Oct 1, 2012 · I came across this post today as I was trying to gather the time difference between fields located in separate tables joined together on a key field. This is the working code for such an endeavor. (tested in sql 2010) Bare in mind that my original query co-joined 6 tables on a common keyfield, in the code below I have removed the other tables ...

  8. SQL Calculate time difference between two times and show the …

    May 1, 2020 · Since you are wanting fractional hours, then you will need to get the date difference in minutes; divide by 60; and then cast that to either a decimal or numeric datatype. The last step is important because if you do not cast to a decimal, and specify the number of decimal digits, then the result will be rounded.

  9. Calculate difference between two timestamps in SQL in the same …

    Oct 5, 2015 · In the difference column i have te same number. For example: i have this 3 rows 2015-07-26 22:42:03.0000000 / 2015-07-26 22:42:03.0000000 / 2015-07-27 07:07:16.0000000. As you see the first 2 are equals so in the difference column i have the same number for the first 2 that is the difference between the 2nd one and the 3er one. –

  10. How to calculate difference between 2 times in SQL

    May 25, 2015 · DECLARE @null time; SET @null = '00:00:00'; SELECT DATEADD(SECOND, - DATEDIFF(SECOND, End_Time, Start_Time), @null) Reference: Time Difference. Edit: As per the comment, if the difference between the end time and the start time might be negative, then you need to use a case statement as such

Refresh