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.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,300 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jerry Xu-MSFT 7,946 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