Forum Discussion

AndyHoit's avatar
AndyHoit
Copper Contributor
May 09, 2019
Solved

SharePoint Date Column Color Formating

I am in SharePoint online in the new Experience. I have a date column called I am trying to modify the default Color formatting in a date column. I would like to change the first one from "before ...
  • Norman Young's avatar
    Norman Young
    May 13, 2019

    Hi AndyHoit,

     

    Code appended below.

     

    I hope this helps.

     

    Norm

     

    ===

     

    {
    "elmType": "div",
    "style": {
    "padding": "0 4px"
    },
    "attributes": {
    "class": {
    "operator": ":",
    "operands": [
    {
    "operator": "==",
    "operands": [
    "@currentField",
    ""
    ]
    },
    "",
    {
    "operator": ":",
    "operands": [
    {
    "operator": "<",
    "operands": [
    {
    "operator": "Date()",
    "operands": [
    {
    "operator": "toDateString()",
    "operands": [
    "@currentField"
    ]
    }
    ]
    },
    {
    "operator": "Date()",
    "operands": [
    {
    "operator": "toDateString()",
    "operands": [
    {
    "operator": "+",
    "operands": [
    "@now",
    -259200000
    ]
    }
    ]
    }
    ]
    }
    ]
    },
    "sp-css-backgroundColor-errorBackground50",
    {
    "operator": ":",
    "operands": [
    {
    "operator": "==",
    "operands": [
    {
    "operator": "Date()",
    "operands": [
    {
    "operator": "toDateString()",
    "operands": [
    "@currentField"
    ]
    }
    ]
    },
    {
    "operator": "Date()",
    "operands": [
    {
    "operator": "toDateString()",
    "operands": [
    "@now"
    ]
    }
    ]
    }
    ]
    },
    "sp-css-backgroundColor-blueBackground37",
    {
    "operator": ":",
    "operands": [
    {
    "operator": ">",
    "operands": [
    {
    "operator": "Date()",
    "operands": [
    {
    "operator": "toDateString()",
    "operands": [
    "@currentField"
    ]
    }
    ]
    },
    {
    "operator": "Date()",
    "operands": [
    {
    "operator": "toDateString()",
    "operands": [
    "@now"
    ]
    }
    ]
    }
    ]
    },
    "sp-css-backgroundColor-successBackground50",
    ""
    ]
    }
    ]
    }
    ]
    }
    ]
    }
    },
    "txtContent": "@currentField"
    }

Resources