Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

THEMA: Date condition based on token attribute

Date condition based on token attribute 1 Jahr 1 Woche her #98050

  • kateibe
  • kateibes Avatar
  • OFFLINE
  • Junior Lime
  • Beiträge: 21
  • 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
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Date condition based on token attribute 1 Jahr 1 Woche her #98055

  • DenisChenu
  • DenisChenus Avatar
  • OFFLINE
  • Moderator Lime
  • Beiträge: 6207
  • Dank erhalten: 788
  • Karma: 238
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
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: kateibe

Date condition based on token attribute 1 Jahr 1 Woche her #98144

  • kateibe
  • kateibes Avatar
  • OFFLINE
  • Junior Lime
  • Beiträge: 21
  • 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
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Date condition based on token attribute 1 Jahr 1 Woche her #98159

  • DenisChenu
  • DenisChenus Avatar
  • OFFLINE
  • Moderator Lime
  • Beiträge: 6207
  • Dank erhalten: 788
  • Karma: 238
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
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: kateibe

Date condition based on token attribute 1 Jahr 1 Woche her #98244

  • kateibe
  • kateibes Avatar
  • OFFLINE
  • Junior Lime
  • Beiträge: 21
  • 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 :)
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Moderatoren: ITEd
Ladezeit der Seite: 0.150 Sekunden
Donation Image