SharePoint Format Date In View With JSON

On 06/09/2024

In SharepointOnLine

Format date background color in your SharePoint list with JSON

Json dateformatting

 


{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "txtContent": "@currentField",
    "style": {
       "background-color": 
       {
          "operator": "?",
          "operands": [
             {
                "operator": ">=",/*if the date is greater than tomorrow  24x60x60x1000 = 86400000 = 1day    */
                "operands": [
                   "@currentField",
                   {
                      "operator": "+",
                      "operands": [
                         "@now",
                         86400000
                      ]
                   }
                ]
             },
             "red",
             {
                "operator": "?",
                "operands": [
                   {
                      "operator": "<=",/*if the date is less than today - 60 days*/
                      "operands": [
                         "@currentField",
                         {
                            "operator": "-",
                            "operands": [
                               "@now",
                               5184000000 /* 86400000 x 60 */
                            ]
                         }
                      ]
                   },
                   "yellow",
                   "transparent"
                ]
             }
          ]
       }
    }
  }

 

Sharepoint JSON Formatting

No ratings yet - be the first to rate this.