Search code examples
timegoogle-sheetsstring-formattinggoogle-sheets-formulaarray-formulas

Formula of Google Sheet to compute the rest of 24 hour duration from a timestamp?


In the cell A2, there is the timestamp, say 21:35, I'd like to calculate the remaining time to midnight. It's essentially, 24 hours minus 21:35. But I want to have a formula for the calculation.

I found that if I put 24:00 in a cell, B1, then the formula below works: =B1-A2 but I'd like to have a formula without reference to another cell for the 24:00 constant? I guess there might be a way to express the constant of 24:00 as the duration in formula?


Solution

  • try simply:

    ="24:00:00"-A1
    

    0


    for ArrayFormula try:

    =ARRAYFORMULA(IF(A1:A; TEXT("24:00:00"-A1:A; "hh:mm"); ))
    

    0