In SharePoint O365, in the modern experience, I have a list of training certificates that have an expiration date of one year from date taken.
I would like to use conditional formatting to create a status column that shows me the certificate is one of these:
Current, green background - taken sometime within the last 10 months.
Expiring, Orange background - Taken 11 or 12 months ago.
Expired, Red background - date past one year ago
I have done this for another list using the status of the request of whether it was approved or rejected but when it comes to dates I have found it rather difficult to get an example even close to what I am looking for. I used the formatting wizard that is not built in but it only compares to todays date and I can't use the date of a field.
THE ANSWER:
{
"elmType": "div",
"style": {
"background-color": "=if(@currentField >= @now - 26297460000 ,'green', (if(@currentField > @now - 31556952000, '#F07440','red'))"
},
"children" :[
{
"elmType": "span",
"txtContent" : "=if(@currentField >= @now - 26297460000 ,'Current', (if(@currentField > @now - 31556952000, 'Expiring','Expired'))",
"style": {
"color": "white"
}
}
]
}