Format a time span as a number of days, hours and minutes

后端 未结 7 943
夕颜
夕颜 2020-12-11 00:50

This is purely an Excel sheet question.

I have a time span that is basically a difference between two cells, each containing a date:

I have managed to get th

7条回答
  •  攒了一身酷
    2020-12-11 01:25

    Had a similar kind of question, except for me, I needed hours divided by 8, instead of 24, as I needed working days. So I came up with a solution, but it's really really complex to understand because the code looks like a mess, but if you segment them, it's not that hard.

    =CONCAT(INT(C16*24/8),":",IF(INT((C16-INT(C16))*24)<10,CONCAT("0",INT((C16-INT(C16))*24)),INT((C16-INT(C16))*24)),":",IF(MINUTE(C16)<10,CONCAT("0",MINUTE(C16)),MINUTE(C16)))
    
    • Note that I have used "8" to divide the hours by 8 because I needed working hours. So you can neglect that if you do not want it
    • I needed to display the result as "4:09:08" rather than "4:9:8". (This is in "Days:Hours:Minutes" format). That's why I have used extra IF() and CONCAT() functions inside.

提交回复
热议问题