"Friendly" date display format combine with custom json formatting

Iron Contributor

Is there a way to combine the great "friendly date display format" native to SharePoint Online with custom formatting of the date field using JSON? My goal is to color the date field red when it's prior to the current date, but I'd like it to use the friendly-type values.Choosing "friendly" in the list settingsChoosing "friendly" in the list settings

 

value displaying like I'm hoping for, minus the colorvalue displaying like I'm hoping for, minus the color

 

adding the json to add the color also negates the "friendly" date display format.adding the json to add the color also negates the "friendly" date display format.

 

3 Replies

@Ian Bruckner, sorry to dig up an old post, but did you figure out a solution?  I'm trying to do the same thing here.

@Ian Bruckner 

 

Hi,

 

I know, this is an old thread, but answering it in case other people are struggling with this. To achieve this have txtContent value as [$ColumnInternalName.displayValue] not @currentField. For example, my full code is as follows for the column AppSecretExpiration.

 

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

  

@currentField.displayValue worked for me.