Calculate time difference in excel

后端 未结 3 1622
梦毁少年i
梦毁少年i 2021-01-28 13:11

I have a two dates in excel \"1/2/2016 01:56:05\" and \"8/3/2016 06:21:46\". How do I calculate the time difference between them in a format of days and hours?

Thanks!

3条回答
  •  耶瑟儿~
    2021-01-28 13:18

    I prefer to work with dates as decimals. It looks cumbersome, but I'm much happier knowing what it's doing.

    What I would usually do is to have A1-A2 in cell A3, then work out the component parts separately:

    Days: =INT(A3)
    Hours: =INT((A3-INT(A3))*24)
    Minutes: =INT(((A3*24)-INT(A3*24))*60)
    

    Or if you wanted to do it all in one formula:

    =INT(A3)&" days, "&INT((A3-INT(A3))*24)&" hours, "&INT(((A3*24)-INT(A3*24))*60)&" min"
    

    or without using A3

    =INT(A1-A2)&" days, "&INT(((A1-A2)-INT(A1-A2))*24)&" hours, "&INT((((A1-A2)*24)-INT((A1-A2)*24))*60)&" min"
    

    It's not the prettiest or most efficient method but you can see how the times are calculated this way.

提交回复
热议问题