0

I have a Modern SharePoint list with a Review Date column. I'm trying to configure JSON so that if the entry has Today's Date, it will highlight Red. If it is between today and 15 days from now, it will highlight Yellow.

I'm just not sure how to write those conditions together, and include the 15 days syntax. Any help would be appreciated!

Thank you.

1 Answer 1

2

Use this JSON code in SharePoint column formatting for your date column:

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "txtContent": "@currentField",
    "style": {
        "color": "black",
        "background-color": "=if(Number(@currentField) == 0, '', if(toLocaleDateString(@currentField) == toLocaleDateString(@now), 'red', if(@now < @currentField && @currentField <= addDays(@now, 15), 'yellow', '')))"
    }
}

Output:

enter image description here

1
  • 1
    This worked perfectly. Thank you!!
    – Chris
    Sep 22, 2022 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.