I've been reading a lot of questions and answers, and I still can't figure out how to get this to work, so I'll ask here.
I have a Microsoft Form that I've connected to my SharePoint list. One of the questions on the Form asks users to select a date. When the date appears in the SharePoint list, I want its background color to be determined by how distant in time that date is relative to today.
I want the background to be green if the date is more than 180 days away, yellow if it's equal to or less than 180 days away, orange if it's equal to or less than 90 days away, and red if it's in the past.
I used Photoshop to find hex codes of the four shades I want: green (#72cf68), yellow (#e9e372), orange (#eb8147), red (#d13e3e).
Below is the code I made after reading many different questions and answers. I can't figure out why it won't work.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"background-color": "=if(Number(@currentField > @now + 15552000000, '#72cf68', if(@currentField <= @now + 15552000000, '#e9e372', if(@currentField <= @now + 7776000000, '#eb8147', if(@currentField < @now, '#d13e3e'))))"
}
}
Thank you for reading.
