I'm currently looking at finding time differences between dates and outputting to hours (00:00). However, I'm then going on to sum this calculation which means I can't convert to char/varchar.
Please see example data below how I would like it to appear.
EMPLOYEE_ID Start End Duration
1 05/06/2015 08:30 05/06/2015 12:12 03:42
1 05/06/2015 13:18 05/06/2015 17:00 03:42
1 06/06/2015 08:30 06/06/2015 12:12 03:42
1 06/06/2015 13:18 06/06/2015 17:00 03:42
Current code for Duration:
CONVERT(varchar(5),DATEADD(minute,DATEDIFF(minute,Start, End),0), 114) as Duration
Obviously, this code is not how I want it as it's varchar and I'd like to go on to sum two durations together. I have looked around but can't find anything which shows how this would be done.
Calculate the duration in minutes:
This is much easier to work with. Then sum the minutes:
I would recommend leaving it like this. But if you want it in HH:MM format, then manually convert to a string of the format you want.
Don't use a
timedata type. It is limited to 24 hours.