Wednesday, July 24, 2019

SharePoint Online List view formatting : Highlight a row with color if today is the value of a datefield

This is not as straightforward as one would assume.  If you try to compare the value of the date field to the @now variable, it doesn't work.  You have to do a bit of comparison with subtracting milliseconds from the @now.  I had a date field called 'Est DC' in a SharePoint list, see below for my solution.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "additionalRowClass": "=if([$Est_x0020_DC]  <= @now  && [$Est_x0020_DC]  >= @now - 86400000, 'sp-field-severity--good', '')"
}

Hope that helps someone.