I have a data set where the data has to be processed within 28 days of a date field. I have four subcategories within this cycle: First 12 days, First 17 days, First 20 days, and Last 8 days. Each time period within this cycle represents a different procedure that must be done. I know this:
if (DateDiff(Now(), Date($feature.<FieldName>), 'days') <= 12) {
return "First 12 Days" }
else if ....
But this isn't a closed loop. At the end of the cycle, whatever wasn't processed needs to restart the cycle. But of course the date in the date field will show it being more than 28 days later. How can I write an expression in the symbology area that will reset a point's symbology every 28 days without writing out an infinite number of days into the future?
Solved! Go to Solution.
var diff = DateDiff(Today(), $feature.Field, "days")
var overdue = diff > 28
diff = diff % 28 // modulo operation: divide by 28 and take the rest
var period = When(
diff > 20, "Last 8 days",
diff > 17, "First 20 days",
diff > 12, "First 17 days",
"First 12 days"
)
return period + IIf(overdue, " (overdue)", "")
var diff = DateDiff(Today(), $feature.Field, "days")
var overdue = diff > 28
diff = diff % 28 // modulo operation: divide by 28 and take the rest
var period = When(
diff > 20, "Last 8 days",
diff > 17, "First 20 days",
diff > 12, "First 17 days",
"First 12 days"
)
return period + IIf(overdue, " (overdue)", "")
Wow, that was a lot simpler than I was anticipating. Thank you so much!