Forum Discussion
spinman
Dec 18, 2019Tin Contributor
JSON Help Needed
I have a list with two dates one labeled "Effective Date" and one labeled "Exp Date". Both columns are using the Date & Time column type but set to Date Only. What I'm trying to figure out is how to make the "Exp Date" Green if a date is entered and it is not within 30 days of the "Effective Date" field. If the "Exp Date" is 30 days or less of the "Effective Date" field make it Red. Below is some JSON I've been missing with but can't get it to work for my use case. Any help would be much appreciated.
{
"$schema": "<a href="http://columnformatting.sharepointpnp.com/columnFormattingSchema.json" target="_blank">http://columnformatting.sharepointpnp.com/columnFormattingSchema.json</a>",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"background-color":
{
"operator": "?",
"operands": [
"=length([$Effective_x0020_Date]) > 0",
{"operator":"?",
"operands":[
{"operator":"<",
"operands": [
"[$Effective_x0020_Date]","[$Exp_x0020_Date]"
]},"",
{"operator":"?",
"operands":[
{"operator":"<","operands":[
"[$Effective_x0020_Date]",
{
"operator": "+",
"operands": [
"[$Exp_x0020_Date]",
2592000000
]
}]},"green","red"
]},""
]}
,""
]
}
}
}No RepliesBe the first to reply