Welcome, Guest
Username: Password: Remember me

TOPIC: Date condition based on token attribute

Date condition based on token attribute 1 year 2 months ago #98050

  • kateibe
  • kateibe's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 23
  • Karma: 0
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
The administrator has disabled public write access.

Date condition based on token attribute 1 year 2 months ago #98055

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6334
  • Thank you received: 818
  • Karma: 243
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
The administrator has disabled public write access.
The following user(s) said Thank You: kateibe

Date condition based on token attribute 1 year 2 months ago #98144

  • kateibe
  • kateibe's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 23
  • Karma: 0
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
The administrator has disabled public write access.

Date condition based on token attribute 1 year 2 months ago #98159

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6334
  • Thank you received: 818
  • Karma: 243
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
The administrator has disabled public write access.
The following user(s) said Thank You: kateibe

Date condition based on token attribute 1 year 2 months ago #98244

  • kateibe
  • kateibe's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 23
  • Karma: 0
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 :)
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.107 seconds
Donation Image