Forum Discussion
Conditional Formatting in Sharepoint List based on expiry date within 30 days
SLCLARKE23 dates in JSON use milliseconds. So 60 days is 5184000000 milliseconds:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"background-color": "=if(@currentField > @now+5184000000, 'green', if(@currentField > @now && @currentField < @now+5184000000, 'orange', 'red')",
"color": "white"
}
}
Rob
Los Gallardos
Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)
With the current JSON the empty fields get red as well
- ganeshsanapFeb 19, 2024MVP
You can find different/multiple ways to check if SharePoint date & time column is empty or not using JSON formatting at: SharePoint JSON formatting: Check if date & time column is blank/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.
- Rob_ElliottFeb 19, 2024Bronze Contributor
SOE_Tech if the current field is empty then use =if(Number(@currentField)==0,'', if.....
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "txtContent": "@currentField", "style": { "font-weight": "bold", "background-color": "=if(Number(@currentField) == 0, '', if(@currentField <= addDays(@now, 30), 'red', if(@currentField > addDays(@now, 30) && @currentField < addDays(@now, 60), 'orange', '#006666')))", "color": "white" } }
Rob
Los Gallardos
Microsoft Power Automate Community Super User.
Principal Consultant, SharePoint and Power Platform WSP Global (and classic 1967 Morris Traveller driver)