Forum Discussion

PaulvDG's avatar
PaulvDG
Copper Contributor
Mar 17, 2023
Solved

Sharepoint List column date conditional format

Can someone see whats wrong with this please?

Should turn date bold if over 30 days ago but returns nothing

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "style": {
  "font-weight": "=if((Number(@now) - Number(@currentField))/(24*60*60*1000) >= 30, 'bold', 'normal')"
  }
}
  • PaulvDG Here's example using similar JSON: 

     

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "txtContent": "@currentField",
      "style": {
        "font-weight": "=if(@currentField <= addDays(@now,-30), 'bold', 'normal')",
        "color": "=if(@currentField <= addDays(@now,-30), 'red', '')"
      }
    }

     

    Output


    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.

    For SharePoint/Power Platform blogs, visit: Ganesh Sanap Blogs

  • PaulvDG Here's example using similar JSON: 

     

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "txtContent": "@currentField",
      "style": {
        "font-weight": "=if(@currentField <= addDays(@now,-30), 'bold', 'normal')",
        "color": "=if(@currentField <= addDays(@now,-30), 'red', '')"
      }
    }

     

    Output


    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.

    For SharePoint/Power Platform blogs, visit: Ganesh Sanap Blogs

  • PaulvDG Try this cleaner & simple JSON: 

     

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "txtContent": "@currentField",
      "style": {
        "font-weight": "=if(@currentField <= addDays(@now,-30), 'bold', 'normal')"
      }
    }

     


    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.

    For SharePoint/Power Platform blogs, visit: Ganesh Sanap Blogs

Resources