Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

THEMA: Branching off date question in MM/YYYY format

Branching off date question in MM/YYYY format 3 Monate 6 Tage her #107635

  • BrndsRa
  • BrndsRas Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Branching off date question in MM/YYYY format 3 Monate 6 Tage her #107636

  • mfaber
  • mfabers Avatar
  • OFFLINE
  • Expert Lime
  • Beiträge: 82
  • Dank erhalten: 21
  • 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!
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Branching off date question in MM/YYYY format 3 Monate 6 Tage her #107638

  • BrndsRa
  • BrndsRas Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Branching off date question in MM/YYYY format 3 Monate 6 Tage her #107642

  • mfaber
  • mfabers Avatar
  • OFFLINE
  • Expert Lime
  • Beiträge: 82
  • Dank erhalten: 21
  • Karma: 4
Can you attach a test survey and i'll try to look into it...
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Branching off date question in MM/YYYY format 3 Monate 6 Tage her #107643

  • BrndsRa
  • BrndsRas Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 4
  • Karma: 0
Thanks for looking at this. A test example is attached. I used the formula you suggested in the relevance equation.
Anhang:
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Branching off date question in MM/YYYY format 3 Monate 6 Tage her #107653

  • mfaber
  • mfabers Avatar
  • OFFLINE
  • Expert Lime
  • Beiträge: 82
  • Dank erhalten: 21
  • 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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Branching off date question in MM/YYYY format 3 Monate 5 Tage her #107669

  • BrndsRa
  • BrndsRas Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Branching off date question in MM/YYYY format 3 Monate 5 Tage her #107671

  • mfaber
  • mfabers Avatar
  • OFFLINE
  • Expert Lime
  • Beiträge: 82
  • Dank erhalten: 21
  • 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)
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Moderatoren: ITEd
Ladezeit der Seite: 0.140 Sekunden
Donation Image