Extract Month from Date and Use it as a Skip Logic

Hello everybody!

I have a similar problem…
The problem is that I cannot compare dates for the calculation.
What I need is:
Q1: Survey date
Q2: Harvest questions (only for the months of March, April and May)
Q3: planting questions (only for September and October)

How can I make the logical skip in that case?

Hi @elvira_rios
I have moved your discussion into a new topic since this is an advanced calculation with dates. I would recommend the following approach.

  • Extract the number of days using decimal-date-function and subtract the first date of the year from it.
  • Create a skip logic using the days’ bands that fit within the months you expect.

See screenshot below

Use month as skip routine.xlsx (19.1 KB)

Test this on ODK - XLSForm Online v2.x and preview.

Stephane

2 Likes

:heart_eyes:
Beautiful!
Thank you so much!!!

2 Likes

Hello @elvira_rios,
I think, you could also just use the %n option to directly select the month from the survey date (and check it against 3, 4, 5 in your harvest relevant and against 9, 10 for the planting relevant)… See
https://getodk.github.io/xforms-spec/#fn:format-date

3 Likes

And how exactly would the calculation formula be? Like this?

format-date(${date}, %n)

@elvira_rios, this post discussed previously should help you explain how the formula looks like: