Sep 12 2023 07:12 PM
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
Sep 12 2023 10:25 PM - edited Sep 12 2023 10:32 PM
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:
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.