I have a table which had a date column of date type, and timein and timeout columns of type varchar(max).
I'm trying to calculate the total hours between timein and timeout, but I can't because I can't figure out how to convert the varchar to a time format.
So far I've tried CAST(x, AS time), CONVERT(time, x, 114) (also 108) and I keep getting errors
Conversion failed when converting date and/or time from character string
Any help you can give is appreciated in advance.
My table's date looks like this:
| EmpID | Date | TimeIn | TimeOut |
|---|---|---|---|
| 123456 | 2021-12-13 | 05:55 | 14:30 |
Expected result:
| EmpID | Date | TimeIn | TimeOut | Total_hrs |
|---|---|---|---|---|
| 123456 | 2021-12-13 | 05:55 | 14:30 | 8:35 |