I am trying to update conditional formatting of a column to change color to red, when expiration date in the column is 30 days prior to expiring.

1 Answer 1


Open the column formatting pane --> open the drop-down menu under 'ExpiryDate' column --> Under Column Settings, choose Format this column --> Under Format Columns, use below JSON.

  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "debugMode": true,
  "txtContent": "@currentField",
  "style": {
    "color": "=if([$ExpiryDate] - 2592000000 <= @now , '#ff0000','')"

For a day, add milliseconds (2460601000 = 86,400,000). You need to add 30 days so (30246060*1000 = 2,592,000,000).

Also, here the ExpiryDate is the internal name of the column.

The red color will be applied to all the expired items and an item whose expiry is within the next 30 days.

For more reference, please refer Use column formatting to customize SharePoint.

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.