Date constraint - last 365 days from the data collection date

I want to send a constraint message if date field filled with a date that more than 365 days over from the data collection date.

Looking for support

@silasdasgupta, maybe this post discussed previously should help you solve your issue:

Feel free to reach us back if it’s something different you are looking out for.

This is not actually I am looking for. I will not rigid with a specific date. It will be calculated 365 days from the date of data collection. So it will vary.

Example: If I collect data on 1st December 2024 than it will consider date range up to 30 Nov 2023. On the other hand if I collect data on 15th December 2024 then it will consider date range up to 14th December 2023.

Thanks.

@silasdasgupta, if that is the case then maybe you could do it as outlined in the image shared below:

In the survey tab of your XLSForm:

Data entry screen as seen in Enketo: when a date is entered that before 365 days

Data entry screen as seen in Enketo: when a date is entered that after 365 days

Data entry screen as seen in Enketo: when a date is entered within the specified range of 365 days

Reference XLSForm:

Date Constraint.xls (37 KB)

Note: The reference of 365 days is calculated as of today’s date input.

Many thanks. This is actually what I was looking for. :grinning:

1 Like

@silasdasgupta, :bowing_man: :heart: :pray:

Hint: Take care, today() function as calculation will always update when form is opened/saved, incl. for view/edit on server level. If you need the (fixed) start of the form you should work with metadata today (or start).

1 Like