in

Join Hours and Minute column for showing in Decimal format SQL Query


Hello members and Happy New year 2022 to all of you

I have two datetime in a SQL table (SQl server)

+————————–+————————+
| CompLast_SignON_datetime | comp_accidentdate_time |
+————————–+————————+
| 16-12-2021 04:08 | 16-12-2021 05:10 |
| 17-12-2021 14:20 | 17-12-2021 20:00 |
| 18-12-2021 12:15 | 18-12-2021 15:25 |
| 22-12-2021 06:00 | 22-12-2021 12:34 |
| 25-12-2021 11:30 | 25-12-2021 21:40 |
| 26-12-2021 21:00 | 27-12-2021 02:50 |
+————————–+————————+
From which I have separated hours and minutes through SQL query

     SELECT CompLast_SignON_datetime, comp_accidentdate_time, CONVERT(INT, ROUND((DATEDIFF(minute, CompLast_SignON_datetime, comp_accidentdate_time)/60),2,1)) AS 'Hours', format(CONVERT(INT, DATEDIFF(minute, CompLast_SignON_datetime, comp_accidentdate_time) - CONVERT(INT,(ROUND((DATEDIFF(minute, CompLast_SignON_datetime, comp_accidentdate_time)/60),2,1))*60)), '00') As 'Minutes' FROM Safety_SIMS

The output is
+————————–+————————+——-+———+
| CompLast_SignON_datetime | comp_accidentdate_time | Hours | Minutes |
+————————–+————————+——-+———+
| 16-12-2021 04:08 | 16-12-2021 05:10 | 1 | 02 |
| 17-12-2021 14:20 | 17-12-2021 20:00 | 5 | 40 |
| 18-12-2021 12:15 | 18-12-2021 15:25 | 3 | 10 |
| 22-12-2021 06:00 | 22-12-2021 12:34 | 6 | 34 |
| 25-12-2021 11:30 | 25-12-2021 21:40 | 10 | 10 |
| 26-12-2021 21:00 | 27-12-2021 02:50 | 5 | 50 |
+————————–+————————+——-+———+

Now, for further grouping the data, i need to join Hours and Minutes column in one column for getting output like this

+————————–+————————+————+
| CompLast_SignON_datetime | comp_accidentdate_time | Duty_hours |
+————————–+————————+————+
| 16-12-2021 04:08 | 16-12-2021 05:10 | 1.02 |
| 17-12-2021 14:20 | 17-12-2021 20:00 | 5.40 |
| 18-12-2021 12:15 | 18-12-2021 15:25 | 3.10 |
| 22-12-2021 06:00 | 22-12-2021 12:34 | 6.34 |
| 25-12-2021 11:30 | 25-12-2021 21:40 | 10.10 |
| 26-12-2021 21:00 | 27-12-2021 02:50 | 5.50 |
+————————–+————————+————+

please help.



Source: https://stackoverflow.com/questions/70542065/join-hours-and-minute-column-for-showing-in-decimal-format-sql-query

GetX Flutter Firebase Auth Example

AWS Announces Further Worldwide Expansion of Local Zones