I’m creating a currency tracker in sharepoint and want to add some coloured date formatting.
My parameters are the following:
- Expired including today ( #ff7676)
- Expiring in the next 2 months (#ffcf76)
- More than 2 months (none)
I’ve tested a few other scripts and none of them have had the required outcome. Posted below.
Appreciate any help! Thanks!
Test 1:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"background-color": "=if(@currentField >= @now + 2678400000 || @currentField <= @now - 62208000000,'none', '#ffcf76')"
}
}
Test 2:
{
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "=if([$DueDate]>(@now +10368000000), 'Green', if([$DueDate]>@now && [$DueDate]< (@now +10368000000), 'Expiring', 'Expired'))",
"style": {
"background-color": "=if([$DueDate]>(@now +10368000000), 'Green', if([$DueDate]>@now && [$DueDate]< (@now +10368000000), 'Orange', 'Red'))",
"color": "black",
"font-size": "1.5em",
"justify-content": "center"
}
}