Date comparison in Json for column formatting in a list

Copper Contributor

HI

In the Json Panel for formatting a list column, I'm trying to compare two columns [DATE FIN] and [CODE PROJET.DATE RECONDCT].

[DATE FIN] is in date format in my Sharepoint list. But  I'm not sure [CODE PROJET.DATE RECONDCT] is in date format because it comes in date format from another list.

 

So I tried this =>

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"debugMode": true,
"txtContent": "@currentField",
"style": {
"padding": "0 4px",
"background-color": {
"operator": "?",
"operands": [
{
"operator": "<",
"operands": [
"date([$CODE_x0020_PROJET.DATE_x0020_RECONDCT])","date(toLocaleString([$DATE_x0020_FIN]))"
]
},
"#facfd3",
"#f1f7ce"
]
}
}
}

 

This json works but gives a wrong comparison. I supposed I got a problem of date format. So I tried first to compare the columns directly, then to convert with a localString the one coming from the other list... but these comparisons are always wrong.

 

What do I have to do, to compare correctly these two columns?

Thanks for you help.

 

NB: when I access with power bi to these data, I get text format as DD/MM/YY hh:mm:ss for both columns.

 

2 Replies

@Patgat 

 

Is this column [CODE PROJET.DATE RECONDCT] added to your main list using the lookup column (as additional field) from another SharePoint list?


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

Hi ganesh
Yes it is.