0

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"
  }
}
0

Check as following:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
    "background-color": "=if(@currentField <=@now,'#ff7676',if(@currentField <=@now+5184000000 && @currentField>@now,'#ffcf76',if(@currentField>@now+5184000000,'','')"
  }
}

Result:

enter image description here

2
  • Thanks Julie. Works perfectly! May 18 at 11:25
  • Remember to mark the reply as answer if it helps you, which will be beneficial to other community members reading this thread.
    – Julie_MSFT
    May 19 at 1:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.