Forum Discussion
Jorge0008
Jul 21, 2022Copper Contributor
Expiration date after a set time
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 l...
Jorge0008
Jul 21, 2022Copper Contributor
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', ''))))"
}
}
{
"$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', ''))))"
}
}