Unable to conditionally format a column using JSON format.

Jonathan Kearney 20 Reputation points
2026-08-06T13:06:04.0266667+00:00

I currently have a list in Microsoft Teams that has a column titled "12 Month Due Date". I would like to make the background of the cell turn red if the date entered is within the active month or past due. I do not understand how to utilize JSON format and have been unsuccessful googling options to teach myself.

Microsoft Teams | Microsoft Teams for business | Other
0 comments No comments

Answer accepted by question author
Michelle Nguyen 1,510 Reputation points Independent Advisor
2026-08-06T13:39:11.34+00:00

Hi @Jonathan Kearney

Thank you for reaching out to the community. You can accomplish this by applying JSON column formatting to the 12 Month Due Date column.

The following JSON will highlight the cell in red when the date falls within the current month or is from an earlier month. Blank cells and dates in future months will remain unchanged.

{
 "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
 "elmType": "div",
 "txtContent": "@currentField.displayValue",
 "style": {
 "width": "100%",
 "padding": "4px 8px",
 "box-sizing": "border-box",
 "background-color": "=if(Number(@currentField) == 0, 'transparent', if(getYear(@currentField) < getYear(@now) || (getYear(@currentField) == getYear(@now) && getMonth(@currentField) <= getMonth(@now)), '#d13438', 'transparent'))",
 "color": "=if(Number(@currentField) != 0 && (getYear(@currentField) < getYear(@now) || (getYear(@currentField) == getYear(@now) && getMonth(@currentField) <= getMonth(@now))), 'white', 'inherit')",
 "font-weight": "=if(Number(@currentField) != 0 && (getYear(@currentField) < getYear(@now) || (getYear(@currentField) == getYear(@now) && getMonth(@currentField) <= getMonth(@now))), '600', 'normal')"
 }
}

To apply it:

  1. Open the list in Microsoft Teams.
  2. Select the arrow next to 12 Month Due Date.
  3. Select Column settings and then Format this column.
  4. Select Advanced mode.
  5. Paste the JSON and select Save.

Please note that this formatting highlights every date in the current calendar month, including dates later in the month, as well as dates from previous months.

I hope this helps. If the formatting does not work as expected, please verify that 12 Month Due Date is configured as a Date and Time column.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

0 additional answers

Sort by: Oldest

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.