Date condition based on token attribute

More
4 years 5 months ago #98050 by kateibe
kateibe created the topic: Date condition based on token attribute
Hello,

I have a date questions which I need to compare to a token table attribute. For example:

Users will be asked to enter their Date of birth using a date question type (with dropdown boxes display) and with the input format left blank.

Then I would like to be able to compare this date entered to an attribute in the token table. I have tried everything but nothing seems to work!! :(

Since I left the input format in the date question type blank, I'm assuming this is defaulting to my survey format which is MM/DD/YYYY. In the Token attribute the date is set to the same format for example 03/20/1975. I'm not sure what else could be going on. Please help! Thank you!

Kat

Please Log in to join the conversation.

More
4 years 5 months ago #98055 by DenisChenu
DenisChenu replied the topic: Date condition based on token attribute
Hello,

You have to compare using : strtotime function: manual.limesurvey.org/Question_type_-_Date#Validation_on_date

Abd maybe for the date in token, use some string split to have a "pseudo" date.

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 .
The following user(s) said Thank You: kateibe

Please Log in to join the conversation.

More
4 years 5 months ago #98144 by kateibe
kateibe replied the topic: Date condition based on token attribute
Hi Dennis,

Thank you for your response. Maybe this question is a bit out of my league because I cannot figure out how to make this work! It seems as though it would be so simple. I have tried everything, even using regular regex validation for a "short free type" question.
When I use the following: ^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$ nothing happens after the user enters a date...

I am not sure how strtotime would help in this case, and I am not sure what a "pseudo" date would look like. Any advice you can provide would be greatly appreciated. Thank you!

Kat

Please Log in to join the conversation.

More
4 years 5 months ago #98159 by DenisChenu
DenisChenu replied the topic: Date condition based on token attribute
Put this in your token table YYYYMMDD (for a date of birth at 03/20/1975 : 19750320 ).

And use this validation equation:

date("YYYYMMDD",strtotime(self))==TOKEN:ATTRIBUTE_X

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 .
The following user(s) said Thank You: kateibe

Please Log in to join the conversation.

More
4 years 5 months ago #98244 by kateibe
kateibe replied the topic: Date condition based on token attribute
Hi Dennis,

Thank you for your help in this issue. It still didn't work but I figured out a work around by splitting the date into 3 different fields and adding 3 different attributes. Not the most elegant solution but it works. Thank you for your help anyways!

Kat :)

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!