Forum Discussion
Naligurtan
Jul 27, 2023Brass Contributor
JSON Code for a date column is equal today's date or 30 days to today's date
Hello All, I have a SharePoint list which as several columns. Two of them are date columns. 1-Date revised 2-Next revision date I have a calculated Next revision date column which shows: A...
- Jul 27, 2023Thanks rob. I think you almost got it.
It should be like this:
The Next Revision Date=Date Revised+365 days
Date Revised
If the Next Revision date is now()- 30 days : Amber
If the Next Revision date is greater than now() is: Red
Otherwise show it as Green.
Naligurtan
Jul 27, 2023Brass Contributor
Thanks rob. I think you almost got it.
It should be like this:
The Next Revision Date=Date Revised+365 days
Date Revised
If the Next Revision date is now()- 30 days : Amber
If the Next Revision date is greater than now() is: Red
Otherwise show it as Green.
It should be like this:
The Next Revision Date=Date Revised+365 days
Date Revised
If the Next Revision date is now()- 30 days : Amber
If the Next Revision date is greater than now() is: Red
Otherwise show it as Green.
Naligurtan
Jul 27, 2023Brass Contributor
I found the solution. This works fine.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "[$NextRevisionDate.displayValue]",
"style": {
"background-color": "=if([$NextRevisionDate] > @now, '#FF0000', if([$NextRevisionDate]<(@now-2592000000), '#008000', '#ff8204'))",
"box-sizing": "border-box",
"padding": "0 2px",
"overflow": "hidden",
"text-overflow": "ellipsis"
},
"attributes": {
"class": "sp-css-backgroundColor-BgLightGray sp-field-fontSize13 sp-css-color-white"
}
}
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "[$NextRevisionDate.displayValue]",
"style": {
"background-color": "=if([$NextRevisionDate] > @now, '#FF0000', if([$NextRevisionDate]<(@now-2592000000), '#008000', '#ff8204'))",
"box-sizing": "border-box",
"padding": "0 2px",
"overflow": "hidden",
"text-overflow": "ellipsis"
},
"attributes": {
"class": "sp-css-backgroundColor-BgLightGray sp-field-fontSize13 sp-css-color-white"
}
}