Hello all,
This is more then likely very simple and I’m just overlooking it. But I have been racking my head on this for a couple of days now, and I haven't been able to come up with a viable solution.
I have a start time and an end time with in the same record.
Here is the dataset
ID starttime endtime
------------------------------------------------------ ------------------------------------------------------
1 2004-11-18 04:33:00.000 2004-11-18 14:33:00.000
2 2004-11-18 04:00:00.000 2004-11-18 14:00:00.000
3 2004-11-18 04:00:00.000 2004-11-18 14:00:00.000
4 2004-11-17 04:23:00.000 2004-11-17 14:43:00.000
5 2004-11-16 07:45:00.000 2004-11-16 16:37:00.000
6 2004-11-16 05:56:00.000 2004-11-16 15:45:00.000
---
End dataset
I need to be able to calculate the time difference between the start time and the end time
Example
Start time = 5:30 am
End time = 3:00 pm
Difference = 9:30 hours
I attempted to use the DATEDIFF function but it would always round up to the nearest hour, never showing the minutes
Any thoughts
Thanks
Talenx
This is more then likely very simple and I’m just overlooking it. But I have been racking my head on this for a couple of days now, and I haven't been able to come up with a viable solution.
I have a start time and an end time with in the same record.
Here is the dataset
ID starttime endtime
------------------------------------------------------ ------------------------------------------------------
1 2004-11-18 04:33:00.000 2004-11-18 14:33:00.000
2 2004-11-18 04:00:00.000 2004-11-18 14:00:00.000
3 2004-11-18 04:00:00.000 2004-11-18 14:00:00.000
4 2004-11-17 04:23:00.000 2004-11-17 14:43:00.000
5 2004-11-16 07:45:00.000 2004-11-16 16:37:00.000
6 2004-11-16 05:56:00.000 2004-11-16 15:45:00.000
---
End dataset
I need to be able to calculate the time difference between the start time and the end time
Example
Start time = 5:30 am
End time = 3:00 pm
Difference = 9:30 hours
I attempted to use the DATEDIFF function but it would always round up to the nearest hour, never showing the minutes
Code:
select datediff(mi,starttime,endtime)/60 from Fact_tRouteDetail
--RESULT SET
ID Variance
1 10
2 10
3 10
4 10
5 8
6 9
Any thoughts
Thanks
Talenx