- Posts: 4
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Branching off date question in MM/YYYY format
- BrndsRa
- Topic Author
- Offline
- New Member
Less
More
10 years 1 week ago #107635
by BrndsRa
Branching off date question in MM/YYYY format was created by BrndsRa
Hello,
In my survey I have two question:
Question 1:
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.
Any help appreciated. Thanks.
In my survey I have two question:
Question 1:
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.
Any help appreciated. Thanks.
The topic has been locked.
- mfaber
- Offline
- Junior Member
Less
More
- Posts: 22
- Thank you received: 6
10 years 1 week ago #107636
by mfaber
Replied by mfaber on topic Branching off date question in MM/YYYY format
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"
Hope this helps!
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"
Hope this helps!
The topic has been locked.
- BrndsRa
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
10 years 1 week ago #107638
by BrndsRa
Replied by BrndsRa on topic Branching off date question in MM/YYYY format
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.
The topic has been locked.
- mfaber
- Offline
- Junior Member
Less
More
- Posts: 22
- Thank you received: 6
10 years 1 week ago #107642
by mfaber
Replied by mfaber on topic Branching off date question in MM/YYYY format
Can you attach a test survey and i'll try to look into it...
The topic has been locked.
- BrndsRa
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
10 years 1 week ago #107643
by BrndsRa
Replied by BrndsRa on topic Branching off date question in MM/YYYY format
Thanks for looking at this. A test example is attached. I used the formula you suggested in the relevance equation.
Attachments:
The topic has been locked.
- mfaber
- Offline
- Junior Member
Less
More
- Posts: 22
- Thank you received: 6
10 years 6 days ago #107653
by mfaber
Replied by mfaber on topic Branching off date question in MM/YYYY format
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.
The topic has been locked.
- BrndsRa
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
10 years 6 days ago #107669
by BrndsRa
Replied by BrndsRa on topic Branching off date question in MM/YYYY format
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.
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.
The topic has been locked.
- mfaber
- Offline
- Junior Member
Less
More
- Posts: 22
- Thank you received: 6
10 years 6 days ago #107671
by mfaber
Replied by mfaber on topic Branching off date question in MM/YYYY format
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 manual.limesurvey.org/Question_type_-_Date (minimum and maximum date)
Entering just a four digit year (e.g. "2014") should do the trick.
See manual.limesurvey.org/Question_type_-_Date (minimum and maximum date)
The topic has been locked.