Hi,
I am trying to set a constraint on the date variable which is entered using the information in a note. The enumerator will see a note which has the date of birth. Then, the enumerator will get a date (calendar) question to enter that date of birth into the calendar.
I want to set a constraint that the date entered by the enumerator matches with the date of birth given in the note. Is there a way to do this?
Any help would be highly appreciated.
Welcome to the ODK forum, @mahrukh! We're glad you're here. When you get a chance, please introduce yourself on this other forum thread. I'd also encourage you to add a real picture as your avatar because it helps build community!
What have you tried so far? This should certainly be possible.
Constraints are described in the documentation: https://docs.opendatakit.org/form-logic/#validating-and-restricting-responses
And there are a number of forum threads discussing constraints involving dates:
https://forum.getodk.org/search?q=date%20constraint
Hi guys,
So I just figured out the XForm code for the problem above and I thought to share it with everyone here for future reference.
I have a note displaying the date of birth. The enumerator sees this note and enters this date of birth into a calendar. I wanted to set a constraint for the calendar question that it should exactly match with the note. This is the code I used:
(format-date(${dob_calendar},'%b %d, %Y')) = (${dob_note})
--
Mahrukh Khan
1 Like