Change cell color based on time

I'm trying to change the background color of a cell depending on its relation to a time in another cell, if has no time want the cell to be yellow, if its the same time or before want it to be green, if its after the time want it to be red.

You need to tag your question as Perspective or Vision. The solution will be different for each.

What have you tried and where are you stuck?

Perspective

Please add the tag. Use the 🖉 edit link beside your question title and select Perspective from the dropdown.

You say that you wish to compare times (presumably date-time) but your expression shows that you are comparing dataQuality and text. Do those components hold timestamp values or what?

Tip: post code rather than pictures of code so we can copy it into our expression editor, etc., and our answers.

That's a screenshot from Vision back in a version of 7? Are you sure you're looking for advice in Perspective?

1 Like

Sorry, yes, its vision version 7.

Capture1

Capture1
Want the cell with blue circle to change colors depending on its relation to the red circle cell.

Sorry have the colors backwards.

You should be using dateIsAfter or dateIsBefore to check the values of the relavent dates in your components

... provided that they are datetime and not bits of text. (You didn't respond to my question about that and that's going to make it difficult for folks to help you.)

1 Like

The time that shows up is input by the user and the empty cell gets the time by pressing a button that is associated with the current time.

I would be storing the hh and mm into custom properties on the component (or in tags). Then I would construct a date object in an expression binding on another custom property with:

try(setTime(now(), {hour prop}, {min prop}, 0), None) 

Then in your bg expression you can use:

case(true
  ,isNull({value from above prop}), color(...) 
  ,dateIsBefore(now(), {value from above prop}, color(...) 
  ,dateIsAfter(...), color(...) 
, color(...) 
) 

Forgive the brevity... It's hard to type code on a phone

1 Like

Capture2
The components get the values from tags.