Formating Date Column in Teams List

Copper Contributor

I am really struggling with putting in a formula to highlight dates that are older than 365 days.

 

I would like the Date of Test column to automatically turn red and bold when older than 365days.  Can anyone help with this?

 

Thank you

 

RebeccaS4074_0-1694571121706.png

 

1 Reply

@RebeccaS4074 

 

Try using JSON column formatting like below for your date column: 

 

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
    "font-weight": "=if(@currentField < addDays(@now,-365), 'bold', 'normal')",
    "padding-left": "10px",
    "color": "=if(@currentField < addDays(@now,-365), 'white', '')",
    "background-color": "=if(Number(@currentField)==0, '', if(@currentField < addDays(@now,-365), 'red', ''))"
  }
}

You can also refer SharePoint list column in JSON using their internal names like [$InternalNameOfColumn] instead of @currentField.

 

Related References:

  1. How to find the Internal name of columns in SharePoint Online? 
  2. SharePoint JSON formatting: Check if date & time column is blank/empty 

 

Output

ganeshsanap_0-1694583143837.png


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.