Two dates validation (adding certain number of days to an existing date)

I have two date questions.

  1. Date of Enrolment
  2. Date of follow up visit.

I want to put a validation criteria, wherein my data collectors should be allowed to entered date in the range of 25-35 days to Date of enrolment.

For example if my Date of enrollment is 15.04.2024, then it should only allow the follow up visit dates in the date range of 25-35 days of Date of enrollment.

@Priyanka, FYR …

1 Like

Hi Kalyan!

Thank you for your reply. The solution you have provided in the above query demands a date more than 2021-01-01 or >/= today, however in my case, it will be unique for each patient as the constraint for date of follow up visit question will depend upon the date of enrollment.

Hence requesting you to kindly help me on this.

Thank you.

Regards,
Priyanka

Hi @Priyanka,

Considering your first date picker is named Date1

Putting a validation code in Second Date Picker like this:

. >=(${Date1}+25) and . <=(${Date1}+35)

should work.

If needed I can share the xls form too.

1 Like

@hakan_cetinkaya, :clap: :heart: :partying_face:

1 Like

@Priyanka, this is what @hakan_cetinkaya has advised:

In the survey tab of your XLSForm:

image

Data entry screen as seen in Enekto:

Data entry screen as seen in Enekto:

image

Reference XLSForm:

Date Constraint.xls (37.5 KB)

1 Like

Thank you so much Hakan,

This is exactly what I needed.

2 Likes

Thank you Kalyan. Yes its absolutely working correctly.

2 Likes