I am trying to come with a date validation that displays a certain message when reporting.
I have a question that asks "when was the last report sent?". This report is supposed to be sent between the 1st-5th of each month. So i want that when the date range is between those days, it dispalys a message that says "Timely Sent" otherwise display "Lately Sent".
Anyone available to help?
It's a bit tricky, but that's how I do it
You will add a hidden value for the year and month of date of sending the report
for year: if(int(substr(your_date, 5, 7)) = 1, concat(int(substr(your_date, 0, 4)) - 1, "-"), substr(your_date, 0, 5))
for month: if(int(substr(your_date, 5, 7)) = 1, 12, int(substr(your_date, 5, 7)) - 1)
then for validation
. >= date(concat(year value, month value, "-01")) and .<=date(concat(year value, month value, "-05"))
Hope that helps
Thank you for your help. But I just hve one question, the 'your_date' is a commcare function or I should replace that with an actual date i desire?
Yes dear, you need to put the date you want instead of your_date part
Thanks for your help.
My coleague and I managed to come up with the solution below.
if(int(format-date(#form/question_sample, "%e")) >= 1 and int(format-date(#form/question_sample, "%e")) <= 5, "Timely sent", "Lately sent")
That is for anyone who might be interested.
Happy that it's solved