Search code examples
excelnumbersformatexcel-2013elapsedtime

Excel 2013: Hiding "0 hours 00 minutes" elapsed time


I am customizing Excel's built-in Time Card template to calculate overtime hours per day. I customized the time format as [h] "hours" mm "minutes". But the problem comes for a day which doesn't have overtime hours, so I get "0 hours 00 minutes" in the cell. I want to show '--' in those cells. How do I do that? Thanks.


Solution

  • Enter this custom number format:

    [h] "hours" mm "minutes";;--
    

    UPDATE

    The problem you were experiencing is that Excel is not good with decimal (floating point) arithmetic. It can be off by very tiny amounts. Your calculations that looked like they resulted in zero were instead something like: 0.0000000033.

    To get around this problem I used the MROUND() function to round the calculations to the nearest minute. This resulted in real zeroes and allowed the number format to do its thing.

    Like so:

    =MROUND(E15-G15,60/86400)
    

    The number format given at the top of this answer works perfectly after that.