I have tree columns in one of the tables: check-in time and check-out time, billableHours. check-in & check-out are date fields. billableHours is varchar and would like to format like this: HH:MM.
I could use following query
SELECT CONVERT(VARCHAR,(Checkout-checkIn),108) from WorkTrackingLog
but I get HH:MM:SS
Question # 1: How do I subtract checkout-checkin and get HH:MM?
Now once I get HH:Mm from check-in & check-out date, I would like to add these numbers and get the totalDuration in other table.
For example lets say I have three records:
Table # 1:
------------------------
TicketId | billableHours
------------------------
1001 | 05:04
1001 | 12:19
1001 | 02:16
------------------------
Table # 2
------------------------
TicketId | totalDuration
------------------------
1001 | 19:39
------------------------
Questions # 2 - How do I convert HH:Mm to int and add multiple records together to get totalDuration. Total duration can be varchar format.
Make sense?
thank you in advance for your input/feedback.