Wish to display dates which more than the current date and those less than the current date as "past"

1. What is the problem? Be very detailed.
I am trying to calculate dates that a woman should go for antenatal care. However I wish to only show those dates which are still due and not those that have already passed (using the current date). I have tried to firstly used the calculation this formula format-date(date(decimal-date-time(${last_menstrual})+84), "%d-%m-%Y") to calculate the first ANC date(similarly for all 8 visits) based on the Last menstrual date. I then used this if statement: if(${first_anc_visit} < format-date(date(today()),"%d-%m-%Y"),"past",${first_anc_visit}) so that if the date is less than today's date, it should display "past" otherwise it should display the actual date. The problem is it simply just return dates for all the visits. Sometimes it only gives a single visit as past which is not correct. Is there anywhere am making it wrong or where i can improve the formula.

2. What app or server are you using and on what device and operating system? Include version numbers.
3. What you have you tried to fix the problem?
I have tried to change the dates to be in the same format
4. What steps can we take to reproduce the problem?
I am uploading the snippet code of the form
5. Anything else we should know or have? If you have a test form or screenshots or logs, attach below.
anc_visit_problem.xlsx (16.8 KB)

Hi @newtonnyapwere
welcome to the forum! Please introduce yourself here!

I think you compare dates in a wrong way you need to convert them using decimal-date-time function first. Here is your form with fixes: anc_visit_problem (1).xlsx (9.5 KB)


Thanks https://forum.getodk.org/u/Grzesiek2010 it worked! I am now good to go.

1 Like