Greetings, I want to restrict a date variable in the month-year appearance such that I want responces to be from say Jan-13 to Sep-18.
Hi @bkgwadi,
Please follow the syntax as shown in the image below to display your input date in “month-year appearance” constraining from Jan 2013 to Sep 2018.
Please be aware, the month-year appearance on a date question only affects how the date is displayed, it does not change the fact that a full date is still being stored. Specifically “2019-06” will get stored as 2019-06-01.
This is especially important if you then use these in any comparison calculation. For example, if you want to check if a date is between Dec 2018 (ie >= 2018-12-01) and January 2019, you’d actually probably want to check against February 2019 (ie < 2019-02-01), since January 2019 is actually stored as January 1 (!) 2019.
Kindly note @Kal_Lam post
Please be aware, the month-year appearance on a date question only affects how the date is displayed, it does not change the fact that a full date is still being stored. Specifically
quote=“Xiphware, post:3, topic:4015”]
Please be aware, the month-year appearance on a date question only affects how the date is displayed , it does not change the fact that a full date is still being stored . Specifically
[/quote]
Thank you @Kal_Lam
I have another qualm. I am trying to use this statement to avoid responding to a question already asked.
((${select_survey} != ‘dryland’ and ${select_survey} = ‘livestock’) or (${select_survey} != ‘dryland’))
Check cell J13 on the Excel form, been trying to avoid having to repeat the same question. Where am I going wrong?Outcomes_Test.xlsx (27.7 KB)
Hi
Your constraint has included two conditions that do not work together AND with OR you are better of creating intermediate dummies to cater for a simple AND only or OR only logic.
Regards
Stephane
Hi,
as far as we experienced, there is no problem to combine and with or conditions, IF they are separated by/in brackets, i.e. not evaluated at the same level. Like (a=1 or a=3) and (b=3).
There is another issue in your formula, I think: select_survey is a multiple_selection variable, so you need to work with selected (${select_survey} ‘livestock’) …
Kind regards
FYI these things are unambiguously described in the official XPath Specification regarding the precedence order of operators when evaluating XPath expressions. Specifically, from lowest-to-highest precedence:
...
|4 |or |left-to-right|
|5 |and |left-to-right|
|6 |eq, ne, lt, le, gt, ge, =, !=, <, <=, >, >=, is, <<, >> |left-to-right|
|7 |to |left-to-right|
|8 |+, - |left-to-right|
|9 |*, div, idiv, mod |left-to-right|
Which is to say, AND’s have a higher precedence and are evaluated before ORs (and relational operators before both).
When in doubt, consult the precedence order, or stick a bracket around it
Hello @Kal_Lam , does this constraint work in the offline Kobo collect app? I have tried but it is restricting all the dates but it is working on Enketo online? Is there a solution to that ?
Hi @smbai
could you please share your XLS form?
Stephane
Hi @stephanealoo , thanks for reaching back. Kindky see attached.UCB REGISTRATION TOOL V5.xlsx (13.0 KB)