Forum Discussion
RebeccaS4074
Sep 13, 2023Copper Contributor
Formating Date Column in Teams List
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
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:
- How to find the Internal name of columns in SharePoint Online?
- SharePoint JSON formatting: Check if date & time column is blank/empty
Output:
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.