Date Tests

Check whether a date falls in previous, current, or next weeks and months.

Current Week
Copy  •  js
if(empty(prop("Date")), false, formatDate(prop("Date"), "WY") == formatDate(now(), "WY"))
Explanation
Current Month
Copy  •  js
if(empty(prop("Date")), false, formatDate(prop("Date"), "MY") == formatDate(now(), "MY"))
Explanation
Next Week
Copy  •  js
if(empty(prop("Date")), false, formatDate(prop("Date"), "WY") == formatDate(dateAdd(now(), 1, "weeks"), "WY"))
Explanation
Next Month
Copy  •  js
if(empty(prop("Date")), false, formatDate(prop("Date"), "MY") == formatDate(dateAdd(now(), 1, "months"), "MY"))
Explanation
Previous Week
Copy  •  js
if(empty(prop("Date")), false, formatDate(prop("Date"), "WY") == if(formatDate(prop("Date"), "M") == formatDate(dateSubtract(now(), 1, "weeks"), "M"), formatDate(dateSubtract(now(), 1, "weeks"), "WY"), formatDate(dateSubtract(now(), 1, "weeks"), "W") + formatDate(now(), "Y")))
Previous Month
Copy  •  js
if(empty(prop("Date")), false, formatDate(prop("Date"), "MY") == formatDate(dateSubtract(now(), 1, "months"), "MY"))
Explanation
Combined
Copy  •  js
if(empty(prop("Date")), "", if(formatDate(prop("Date"), "WY") == formatDate(now(), "WY"), "• Curr W", "") + if(formatDate(prop("Date"), "MY") == formatDate(now(), "MY"), " • Curr M", "") + if(formatDate(prop("Date"), "WY") == formatDate(dateAdd(now(), 1, "weeks"), "WY"), " • Next W", "") + if(formatDate(prop("Date"), "MY") == formatDate(dateAdd(now(), 1, "months"), "MY"), " • Next M", "") + if(formatDate(prop("Date"), "WY") == if(formatDate(prop("Date"), "M") == formatDate(dateSubtract(now(), 1, "weeks"), "M"), formatDate(dateSubtract(now(), 1, "weeks"), "WY"), formatDate(dateSubtract(now(), 1, "weeks"), "W") + formatDate(now(), "Y")), " • Prev W", "") + if(formatDate(prop("Date"), "MY") == formatDate(dateSubtract(now(), 1, "months"), "MY"), " • Prev M", ""))
Explanation
Previous & Next