Date conditon

More
5 years 9 months ago #72016 by bonchak
bonchak created the topic: Date conditon
Hello. I have prepared a survey. One of the question has a condition depending on date. In question 3 I ask the birth date. 4th quesiton depends to a condition of birthdate. If the answer is greater or equal to 31.12.1998 than the 4th question can be seen. I can't manage to do this in Limesurvey Version 1.91+ Build 11804. Any suggestions?

Please Log in to join the conversation.

More
5 years 9 months ago #72019 by TMSWhite
TMSWhite replied the topic: Date conditon
bonchak - you can do this in LimeSurvey 1.92 RC2. You have access to the functions mktime() - which has this syntax:

number mktime([hour [, minute [, second [, month [, day [, year ]]]]]])

There are also several ways to either extract the date/month/year parts out of a date you collect (such as substr()), and it may be possible to directly convert the date to a UNIX timestamp.

So, say you have a UNIX timestamp for the birth date, called dob, you could use a relevance equation like this to control whether the 4th question should be seen:
dob >= mktime(0,0,0,12,31,1998)
The following user(s) said Thank You: bonchak

Please Log in to join the conversation.

More
5 years 9 months ago #72020 by bonchak
bonchak replied the topic: Date conditon
Thank you TMSWhite,

I will try to update LimeSurvey, however there are already ongoing survey(s). I will give a try on a local test server and check it.

Best Regards

Please Log in to join the conversation.

More
5 years 9 months ago #72023 by Mazi
Mazi replied the topic: Date conditon
bonchak, did you try using a condition based on a regular expression like "1998-12-31" which is the syntax that is used to store dates?


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 9 months ago #72047 by DenisChenu
DenisChenu replied the topic: Date conditon
Hello,

Without 1.92,
Maybe the best is to do some javacript date diff function ?
  1. On $("#answerXXXX").blur
  2. Split the answer ( $(this).val().split() )
  3. Get the good day/mont/year from the array
  4. Create a new date with this values ( myDate = new Date(myYear, myMonth, myDay)
  5. Get the difference betwwen myDate and 31.12.1998 with gettime javascript function
  6. Put 1, 0 or -1 in another answer
  7. Do your condition for this second answer.


Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
5 years 9 months ago #72061 by Mazi
Mazi replied the topic: Date conditon

Mazi wrote: bonchak, did you try using a condition based on a regular expression like "1998-12-31" which is the syntax that is used to store dates?

I just tested myself and if you use a condition based on a constant like "16.01.2012" it works fine here.


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"
The following user(s) said Thank You: DenisChenu

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now