Forum Discussion
vballnewman
Jan 20, 2022Copper Contributor
Conditional Formatting the most recent three days
I am trying to highlight all rows that have been added to my list in the last three days. The code below is what displays when I choose "on or after" "today". What I really want is "on or after" "tod...
RobElliott
Jan 22, 2022Silver Contributor
vballnewman you can do this with shorter and easier to understand JSON as follows. You'll see that date comparisons are done with milliseconds:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"style": {
"background-color": "=if(@currentField >= @now-172800000,'#ffa558', '')"
},
"children": [{
"elmType": "span",
"style": {
"display": "inline-block",
"padding": "0 4px"
},
"attributes": {
"iconName": "=if(@currentField >= @now-172800000,'FavoriteStar', '')"
}
},
{
"elmType": "span",
"txtContent": "@currentField"
}
]
}
which results in:
Rob
Los Gallardos
Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)