Expiration date after a set time

Copper Contributor

I'm trying to make a formula that will change the color of the date to red if the date is older than 180 days from @now to Yellow if the date is older than 150 from @now and to Green if the date is less than 149 dates old.

 

I been trying lots of different formulas with no joy they only turn one color.

 

I tried modifying this one to do what i was but this one only those it to future dates no passed.

 

{
    "elmType""div",
    "txtContent""@currentField",
    "style": {
        "background-color""=if(Number(@currentField) == 0, '', if(@currentField >= @now + 2592000000, '#AFF8C9', if(@currentField >= @now + 86400000, '#EEBB2F', if(@currentField <= @now, '#F06C47',''))))"
    }
}

 

 

1 Reply
I got it to work:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"background-color": "=if(Number(@currentField) == 365, '', if(@currentField <= @now - 15552000000, 'red', if(@currentField <= @now - 12960000000, 'yellow', if(@currentField <= @now, 'green', ''))))"
}
}