I have a SharePoint list with a date column. I want to format the Dates in the column to be centered with Bold Red Text and keep using the existing background color, if the date is within the last 7 days. I would also like to use the hexadecimal code #FF0000 to represent the red, so I can easily alter the color to a different shade of red, if needed.
1 Answer
See if the following works for you
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"background-color": "=if(@currentField >=(@now -(86400000 * 7)) && @currentField <= (@now), '#FF0000', '')",
"font-weight": "bold",
"justify-content": "center"
}
}
