Need help conditional formatting a date column!

%3CLINGO-SUB%20id%3D%22lingo-sub-1601394%22%20slang%3D%22en-US%22%3ENeed%20help%20conditional%20formatting%20a%20date%20column!%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1601394%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20i've%20had%20a%20look%20through%20previous%20threads%20%26amp%3B%20not%20managed%20to%20find%20the%20answer.%3C%2FP%3E%3CP%3EI'm%20trying%20to%20get%20it%20so%20anything%26nbsp%3B%40now-%202years%20turns%20the%20cell%20background%20red%2C%20but%20anything%20less%20than%202%20years%20ago%20turns%20it%20green.%3C%2FP%3E%3CP%3EThis%20is%20what%20i%20have%20so%20far%20-%20turns%20the%20%2B2yrs%20red%2C%20but%20everything%20else%20is%20just%20a%20different%20shade%20of%20red...%3C%2FP%3E%3CP%3EAny%20help%20greatly%20appreciated!%3C%2FP%3E%3CP%3EThank%20you!!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%7B%0A%20%20%22elmType%22%3A%20%22div%22%2C%0A%20%20%22txtContent%22%3A%20%22%40currentField%22%2C%0A%20%20%22style%22%3A%20%7B%0A%20%20%20%20%22background-color%22%3A%20%22%3Dif(%40currentField%20%26gt%3B%3D%20%40now%20%2B%202592000000%20%7C%7C%20%40currentField%20%26lt%3B%3D%20%40now%20-%2062208000000%2C'red'%2C%20'%23ffa59b')%22%0A%20%20%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1601394%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EConditional%20Formatting%20based%20on%20cell%20colour%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1601437%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20help%20conditional%20formatting%20a%20date%20column!%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1601437%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F765711%22%20target%3D%22_blank%22%3E%40FVaughan%3C%2FA%3E%26nbsp%3B%20there%20should%20be%20a%20minus%26nbsp%3B%3CSTRONG%3E-%3C%2FSTRONG%3E%20instead%20of%20a%20plus%20%3CSTRONG%3E%2B%3C%2FSTRONG%3E%20in%20that%20first%20part%20of%20the%20condition%3A%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3Dif(%40currentField%20%26gt%3B%3D%20%40now%20%2B%202592000000%3C%2FPRE%3E%3CP%3Eas%20you've%20got%20it%20at%20the%20moment%20it's%20looking%20at%20some%20date%20in%20the%20future!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERob%3CBR%20%2F%3ELos%20Gallardos%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23006400%22%3EMicrosoft%20Power%20Automate%20Community%20Super%20User%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1608230%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20help%20conditional%20formatting%20a%20date%20column!%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1608230%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F174092%22%20target%3D%22_blank%22%3E%40Rob%20Elliott%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20that!!%20Silly%20me!%20I%3Bve%20altered%20it%2C%20but%20it%20doesn't%20seem%20to%20have%20changed%20anything.%3C%2FP%3E%3CP%3EI%20still%20have%20some%20dates%20in%20deep%20red%20%26amp%3B%20the%20rest%20in%20light%20red...%3C%2FP%3E%3CP%3EAny%20idea%20on%20how%20to%20make%20the%20ones%20that%20are%202%20years%20overdue%20to%20me%20deep%20red%2C%20but%20everything%20less%20than%202%20yrs%20green%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you!%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi,

 

So i've had a look through previous threads & not managed to find the answer.

I'm trying to get it so anything @now- 2years turns the cell background red, but anything less than 2 years ago turns it green.

This is what i have so far - turns the +2yrs red, but everything else is just a different shade of red...

Any help greatly appreciated!

Thank you!!

 

{
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
    "background-color": "=if(@currentField >= @now + 2592000000 || @currentField <= @now - 62208000000,'red', '#ffa59b')"
  }
}

 

 

2 Replies

@FVaughan  there should be a minus - instead of a plus + in that first part of the condition: 

=if(@currentField >= @now + 2592000000

as you've got it at the moment it's looking at some date in the future!

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User

Hi @RobElliott 

Thanks for that!! Silly me! I;ve altered it, but it doesn't seem to have changed anything.

I still have some dates in deep red & the rest in light red...

Any idea on how to make the ones that are 2 years overdue to me deep red, but everything less than 2 yrs green?

 

Thank you!