Code: rch1birthdate : (Optional question)
Question: In what month and year was nbch1name born?
Help:
Type: Date/Time
Mandatory: No
Relevance equation: ((nbch1dropdown.NAOK == "1"))
Date/Time format: mm/yyyy
Question 2:
Code: rch1barmitz : (Optional question)
Question: Has nbch1name had a if(rch1female == 0, 'bar', 'bat') mitzvah?
Help:
Type: List (radio)
Mandatory: No
Relevance equation: (abs(strtotime(rch1birthdate))) > (abs(strtotime("01-2001")))
Basically, the second question gets asked if the child was 13 or older in Jan 2014. In the initial page view, before question 1 is answered everything appears fine. Question 2 doesn't show up. However, once I select anything (even just the month) in the calendar pop up for question 1, question 2 appears. Even if I select a date that should clearly hide the question, it is still there. This happens regardless of whether I select "Done" on the date picker. This seems to be a problem with the particular formatting for questions 1, (i.e. the MM/YYYY format) or with the date picker design that triggers something that prevents calculation.
I know I can just do the month and year in two separate questions, but I would prefer to have the data collected as 1 date variable.
Dates in Limesurvey are saved as a string (text format). Starting in ver. 2.05+, Expression Manager converts all dates part of an expression into the standard format "yyyy-mm-dd HH:MM:SS". This makes it much easier to compare dates in an expression (e.g. "date1>date2").
Please try comparing to a full date (not only year and month) without strtotime (which is here most likely not necessary). In your relevance equation, try for example: rch1birthdate > "2000-12-31 23:59"
Thanks for that. I tried this, but the problem doesn't seem to be in the expression, but rather in the date picker for the first question. Just clicking on the box and changing something in the picker triggers the second question regardless of the values selected.
You're right, there's indeed a problem with the picker. I try to fix this for the next version of LS. As a workaround, change "Display dropdown boxes" to yes in the advanced attributes of your DOB question. The layout looks very similar to the picker in case of MM/YYYY questions and the relevance works well here.
Thank you very much! This now works.
Is there a way to customize the range of years that appear in the dropdown date picker format? The top year is now 2037 and I can't figure out how to limit this.
Thanks again.
Try the minimum and maximum date fields in the advanced attributes.
Entering just a four digit year (e.g. "2014") should do the trick.
See
www.limesurvey.org/manual/Question_type_-_Date
(minimum and maximum date)