Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

COMPLEX IF STATEMENTS WITH AND / OR

  • SylvainJack
  • SylvainJack's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 2 months ago #233668 by SylvainJack
COMPLEX IF STATEMENTS WITH AND / OR was created by SylvainJack
Please help us help you and fill where relevant:
Your LimeSurvey version: Version 3.19.2
Own server or LimeSurvey hosting:
Survey theme/template:
==================
I am customizing the email that is sent to the form administrator. Inside the mail, I use tests with the keyword "IF".
Some of them work without problem, but others, more complex, do not work. I try to use the keywords "AND" and "OR", but I don't know if I should write AND / OR, or "&&" "||".
Here is the line of code that doesn't work:
{if(strtotime(date("Y/m/d"))>strtotime("2022/11/01")&&strtotime(date("Y/m/d"))<strtotime("2022/12/01"), "Fanny and Sylvain,",")}

I also have another problem: in the form, I use the "OTHER" function: when none of the answers match, the user can enter "another proposal". I can't get the value of what was entered: how to access the variable that stores what the user enters?

 Thanks for your help

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 2 months ago - 2 years 2 months ago #233674 by tpartner
Replied by tpartner on topic COMPLEX IF STATEMENTS WITH AND / OR
I see one too many results in the IF statement.

Try placing it in an equation question in the survey to see the results and check the logic file for error.

Code:
{if(strtotime(date("Y/m/d")) > strtotime("2022/11/01") AND strtotime(date("Y/m/d")) < strtotime("2022/12/01"), "Fanny and Sylvain,")}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 2 years 2 months ago by tpartner.

Please Log in to join the conversation.

  • SylvainJack
  • SylvainJack's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 2 months ago #233678 by SylvainJack
Replied by SylvainJack on topic COMPLEX IF STATEMENTS WITH AND / OR
Works fine indeed !! I feel a bit stupid ;)
Do you know the answer to my other problem concerning the variable that stores whatever the user types in "OTHER" fields ?

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 2 months ago #233727 by tpartner
Replied by tpartner on topic COMPLEX IF STATEMENTS WITH AND / OR
Not without some indication of the question type. Attach a small sample survey (.lss file) containing only the relevant questions.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 2 months ago #233733 by Joffm
Replied by Joffm on topic COMPLEX IF STATEMENTS WITH AND / OR

Do you know the answer to my other problem concerning the variable that stores whatever the user types in "OTHER" fields ?

That was already answered in your other thread about this.

{Q1_other}

 
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose