I am trying to format a sharepoint list with JSON so that the From/To column highlights the current phone number when todays date falls into the timespan given.

enter image description here

I have managed to have past on future dates highlighted with the template from microsoft but it doesn't work properly when trying to highlight todays phone number. I guess it has to do with the fact that time needs to be considered as well.

enter image description here

Very many thanks for any help!

Best regards,


1 Answer 1


Time component is considered automatically.

If I understood correctly what you want it that is Today(date and time) falls between From and To date, you need to highlight phone number.

Idea is to check and compare today's date with From and To one by one.

Pseudo code

If today <= From 
  Do not format
   if today<= To
      Do not format.  

I used below JSON

   "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
   "elmType": "div",
   "txtContent": "@currentField",
   "style": {
      "color": "=if(@now <= [$From], '',if(@now <= [$To],'#ff0000',''))"

Below is output

enter image description here

  • Thanks for the answer. Using the code in JSON sadly it doesn't work and nothing is highlighted regardless of the date... Jun 13, 2019 at 7:23
  • did you changed fields names according to your list? Jun 13, 2019 at 7:25
  • { "$schema": "developer.microsoft.com/json-schemas/sp/…", "elmType": "div", "txtContent": "@currentField", "style": { "color": "=if(@now <= [$From], '',if(@now <= [$To],'#ff0000',''))" } } is how I pasted it which corresponds to what I have in my list... Jun 13, 2019 at 7:25
  • also where are you adding this formatting code ? Jun 13, 2019 at 7:26
  • are you column name 'From' & 'To'? Jun 13, 2019 at 7:26

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.