Constraint and restrict date entries with a special date (if not known) or a range of known dates

Hello!

I have a problem with these date type variables, the syntax are:

.=date(‘01/01/1900’) or (.>=date(‘01/01/2021’) and .<=date(today()))

.=date(‘01/01/1900’) or (.>=date(fecha_nacimiento_m) and .<=date(today()))

I hope you can help me.

Thanks

Hola @christian_silvera

Con tan poca información es complicado ayudar. Para tener más chance de obtener una respuesta lo mínimo es poner capturas de pantalla de la pregunta y los detalles, e incluso mejor poner el cuestionario/parte de el en XLSForm en adjunto. y más que nada una explicación de qué es lo que quieres obtener.

Pero bueno, vamos a intentar:

  • Para referirte a otra pregunta, lo que parece ser el caso con fecha_nacimiento_m, entonces tienes que poner ${nombre_de_la_pregunta}
  • no creo que sea necesario poner “date” antes de today() pero eso te dejo hacer pruebas.
  • habría que revisar si el formato de fecha con “/” está bien o si sería con “-” o todavía otra cosa

También encuentras infos en otra pregunta del foro aquí

Saludos

Hello @Vico!

Thanks for your answer.

My question is regarding what is the syntax in the constraint column.
For example:
I want that in a date type question the pollster can enter the date 01-01-1900 when he does not know and that when he does know the date it can only be between 01-01-2021 and today

@christian_silvera, you could use the following constraint as shown in the image below:

In the survey tab of your XLSForm:

Data entry screen as seen in Enketo: accepting 1900-01-01 when a date is unknown

Image 2

Data entry screen as seen in Enketo: rejecting a date that is above 1900-01-01 and below 2021-01-01

Data entry screen as seen in Enketo: accepting a date that is 2021-01-01 and above

Image 3

Data entry screen as seen in Enketo: accepting a date that is below or equal to today’s date

Image 4

Data entry screen as seen in Enketo: rejecting a date that is above today’s date

Reference XLSForm:

Date Constraint.xls (38 KB)

thank you so much @Kal_Lam . It is exactly what I needed!!!

1 Like