JSON Date - 2 Fields

Portland 21 Reputation points
2021-01-19T12:17:16.367+00:00

Need a little help please. I have 2 SharePoint date type columns in my list. "Due Date" | "Completed Date"

I am looking to set the color in the Completed Date column.

If the Completed Date is before the Due Date, display completed date as green.

If Completed date is after Due Date, display as red.

If completed date equals due date, display as default black text.

Microsoft 365 and Office SharePoint For business Windows
0 comments No comments
{count} votes

Accepted answer
  1. Jerry Xu-MSFT 7,961 Reputation points
    2021-01-20T01:52:29.077+00:00

    Hi, @Portland ,

    Please try the JSON below. Make sure the field name matches the columns in your list.

    {  
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",  
      "elmType": "div",  
      "txtContent": "@currentField",  
      "style": {  
        "color": "=if(@currentField<[$DueDate],'Green',if(@currentField>[$DueDate],'Red','') )"  
      }  
    }  
    

    58394-image.png


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

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