Welcome, Guest
Username: Password: Remember me

TOPIC: Branching off date question in MM/YYYY format

Branching off date question in MM/YYYY format 5 months 2 weeks ago #107635

  • BrndsRa
  • BrndsRa's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
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.
The administrator has disabled public write access.

Branching off date question in MM/YYYY format 5 months 2 weeks ago #107636

  • mfaber
  • mfaber's Avatar
  • OFFLINE
  • Expert Lime
  • Posts: 85
  • Thank you received: 22
  • Karma: 4
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!
The administrator has disabled public write access.

Branching off date question in MM/YYYY format 5 months 2 weeks ago #107638

  • BrndsRa
  • BrndsRa's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
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 administrator has disabled public write access.

Branching off date question in MM/YYYY format 5 months 2 weeks ago #107642

  • mfaber
  • mfaber's Avatar
  • OFFLINE
  • Expert Lime
  • Posts: 85
  • Thank you received: 22
  • Karma: 4
Can you attach a test survey and i'll try to look into it...
The administrator has disabled public write access.

Branching off date question in MM/YYYY format 5 months 2 weeks ago #107643

  • BrndsRa
  • BrndsRa's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
Thanks for looking at this. A test example is attached. I used the formula you suggested in the relevance equation.
Attachments:
The administrator has disabled public write access.

Branching off date question in MM/YYYY format 5 months 1 week ago #107653

  • mfaber
  • mfaber's Avatar
  • OFFLINE
  • Expert Lime
  • Posts: 85
  • Thank you received: 22
  • Karma: 4
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 administrator has disabled public write access.

Branching off date question in MM/YYYY format 5 months 1 week ago #107669

  • BrndsRa
  • BrndsRa's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
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.
The administrator has disabled public write access.

Branching off date question in MM/YYYY format 5 months 1 week ago #107671

  • mfaber
  • mfaber's Avatar
  • OFFLINE
  • Expert Lime
  • Posts: 85
  • Thank you received: 22
  • Karma: 4
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)
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.103 seconds
Donation Image