Forum Discussion
jonboylib
Aug 19, 2022Iron Contributor
SP List Calculated Column Items Expiring Soon
I have a calculated column in my SP list (Renewal Date), it looks at another column (Date Purchased) and adds 4 years to it.
The formula in the calculated column is below;
=TEXT(DATE(YEAR([Date Purchased])+4,MONTH([Date Purchased]),DAY([Date Purchased])))
Now I would like to conditionally format the Renewal Date column, so that if the date is within 6 months of today, add a colour to the cell background, e.g. yellow. Or colour the text red/bold.
How can I achieve this?
- RobElliottSilver Contributor
jonboylib so what have you tried so far?
- jonboylibIron Contributor
RobElliott Think i've figured it out using the code below. Converting 6 months to milliseconds - that correct?
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "txtContent": "@currentField", "style": { "color": "=if(@currentField <= @now, '',if(@currentField <= @now + 15768000000 && @currentField > @now,'orange','green'))" } }
- RobElliottSilver ContributorYes, date comparisons are always in milliseconds in JSON. Good stuff.