Forum Discussion
alandarr
Apr 10, 2020Brass Contributor
Quick JSON formula question regarding date plus 365
I am trying to format a column to change color if TODAY is greater than the date entered, plus 365 days. It's basically to show a color for expiration of date entered. Below is what I was trying to f...
- Apr 13, 2020
Is this what you are looking for?
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"attributes": {
"class": "=if([$DateColumn] >= @now + 365, 'ms-fontColor-themePrimary ms-fontWeight-bold', '')"
}
}I hope this helps.
Norm
Norman Young
Apr 13, 2020MVP
Is this what you are looking for?
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"attributes": {
"class": "=if([$DateColumn] >= @now + 365, 'ms-fontColor-themePrimary ms-fontWeight-bold', '')"
}
}
I hope this helps.
Norm
alandarr
Apr 13, 2020Brass Contributor
Yes that works! I was originally wanting the background to change, but changing the text works great. Many thanks for your help!
- Norman YoungApr 13, 2020MVP
- alandarrApr 13, 2020Brass Contributor
Norman Young Taking another look at that, it still isn't working correctly. I'm trying to color it if it is more than 365 days old from today, i.e. more than a year old.
I've tried to move the formula around, but I still can't get it to do that. Not sure what's going on LOL!
- Norman YoungApr 13, 2020MVPShare your code and what is the column name (internal)?