Forum Discussion
"Friendly" date display format combine with custom json formatting
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 settings
value displaying like I'm hoping for, minus the color
adding the json to add the color also negates the "friendly" date display format.
3 Replies
- AAminMBrass Contributor
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', '')" } }- StephenBlackIron Contributor@currentField.displayValue worked for me.
- E_MahnCopper Contributor
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.