Using date type leads to unexpected behavior

Describe the Bug
I currently face the problem that i can not use the date type for my person-create.xlsx form, since setting the constraint does not work properly.
No matter, what i try, i still get the error, that my date cannot be in the future

I can deploy the default app and get following error, even though the default app has a work-around with the date formatting:

Or I deploy my own config:


How To Reproduce The Issue
List steps for someone trying to reproduce the behavior. For example:

  1. Set-up amazon ec2 instance
  2. Deploy any sample or reference app

Expected Behavior
A short description of what you expected to happen:
Date is accepted and constraint works properly

Environment

  • Instance: cht-test.combacal.org
  • Browser: Any
  • Client platform: MacOS
  • App: webapp
  • Version: 3.13.0 and 3.9.0

Additional Context
I have tried to upload all the 3 different person-create.xlsx from the cht-core config folder and all do not work

Hi @uensal

Can you please share which browser you are using?

@diana I am using the safari browser

Could you please try in Google Chrome or Chromium?

Using chrome works perfectly. Thank you so much for your support! =)

You’re welcome @uensal .
Our browser compatibility scheme can be seen here: Supported Versions | Community Health Toolkit

I have another question concerning calculating the age:
If i try to get the age by having:
type name
date dob1

and then calculate age_in_year with int((today()-${dob1}) div 365.25,0) as it is suggested in Calculate Age in ODK - Support - ODK Forum i get some very strange results like the number 4009654881

format-date(today(), ‘%Y’) - format-date(${dob1}, ‘%Y’) would work, but gives me in general the wrong age.
How would i calculate the age?

Well, both today() and dob1 seem to be be timestamps, numbers of milliseconds since the Unix Epoch. Dividing by 365.25 would require you to work with days, not milliseconds, to get correct results.

Since you work with milliseconds, you would have to divide by 1000 * 60 * 60 * 24 * 365.25.
Alternatively, use difference-in-months (there is one example cht-core/death_report.xml at master · medic/cht-core · GitHub)

1 Like

the approach with “difference-in-months” and the example that i had with death_reports works marvellously.
Big thank you for your support!

2 Likes