Forum Discussion
Conditional Formatting in Sharepoint List based on expiry date within 30 days
ganeshsanap
I am trying to do similar to but flag when modified after 7 days (green), 14 days (amber) and 30 days (red). I cannot seem to work out the code as I am a real noob... what am I doing wrong?
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"background-color": "=if(@currentField >= @now-604800000, 'green', if(@currentField > @now-1209600000 && @currentField <= @now-2592000000, 'amber', 'red')",
"color": "white"
}
}
Beastie1211 Not sure about all your requirements, but try this and see if it works for you:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"background-color": "=if(@currentField >= @now-604800000, 'green', if(@currentField > @now-1209600000 && @currentField <= @now-2592000000, 'amber', 'red'))",
"color": "white"
}
}
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.