Welcome, Guest
Username: Password: Remember me

TOPIC: Date conditon

Date conditon 2 years 9 months ago #72016

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

Re: Date conditon 2 years 9 months ago #72019

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
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 administrator has disabled public write access.
The following user(s) said Thank You: bonchak

Re: Date conditon 2 years 9 months ago #72020

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

Re: Date conditon 2 years 9 months ago #72023

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5331
  • Thank you received: 296
  • Karma: 249
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)limesurvey.org'"
The administrator has disabled public write access.

Re: Date conditon 2 years 9 months ago #72047

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6435
  • Thank you received: 840
  • Karma: 249
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
The administrator has disabled public write access.

Re: Date conditon 2 years 9 months ago #72061

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5331
  • Thank you received: 296
  • Karma: 249
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)limesurvey.org'"
The administrator has disabled public write access.
The following user(s) said Thank You: DenisChenu
Moderators: ITEd
Time to create page: 0.168 seconds
Donation Image