timegoogle-sheetsgoogle-sheets-formulags-conditional-formatting

Time subtraction & conditional formatting in Google Sheets


I'm working on a simple 3-column table for logging sleep hours. It's based on "went to bed" time (col 1), "woke up" time (col 2) and "time in bed" (col 3).

All 3 columns are formatted as - h:mm - and Google seems to calculate the time difference correctly, considering that it has to subtract "backwards", as in "woke up" time minus "went to bed" time.

The problem arises when I add conditional formatting to the "time in bed" column. What I want is the hours spent in bed in green if >= 8:00:00 or in orange if < 8:00:00.

Adding the date as well to the "went to bed" time and "woke up" time didn't help.

The ABS function on the difference didn't help either.

When "time in bed" is >= 8:00:00 AND "went to bed" time happens to be BEFORE midnight, I see an orange number, where I should see a green one

Every other case works as expected.


Solution

  • custom formula for green color:

    =IF(TIMEVALUE(D4)>=0.33,1)
    

    0