Forum Discussion
Conditional formatting in MS Lists
- Dec 13, 2022
Alison50 Use below JSON for date column formatting:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "txtContent": "@currentField", "style": { "background-color": "=if(Number(@currentField) == 0, '', if(toLocaleDateString(@currentField) < toLocaleDateString(@now), 'green', if(toLocaleDateString(@currentField) == toLocaleDateString(@now), 'red', if(@currentField > @now && @currentField <= addDays(@now, 7), 'orange', ''))))" } }
Related read: SharePoint JSON formatting: Check if date & time column is blank/empty - different ways to check if date column is blank or empty
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
Alison50 Use below JSON for date column formatting:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"background-color": "=if(Number(@currentField) == 0, '', if(toLocaleDateString(@currentField) < toLocaleDateString(@now), 'green', if(toLocaleDateString(@currentField) == toLocaleDateString(@now), 'red', if(@currentField > @now && @currentField <= addDays(@now, 7), 'orange', ''))))"
}
}
Related read: SharePoint JSON formatting: Check if date & time column is blank/empty - different ways to check if date column is blank or empty
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.