Welcome to the LimeSurvey Community Forum

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

Date - 60 days (dynamic)

  • rbernhardthki
  • rbernhardthki's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 1 month ago #164380 by rbernhardthki
Date - 60 days (dynamic) was created by rbernhardthki
Hi,

I have a survey where I need to display different text + admin email based on the below:


IF {CommissionDate} >= today's date - 60 days, TRUE, FALSE

I found that to get today's date i can use {date('d/m/Y')} but if I add -60 at the end it displays as "NAN".

I also tried: {(date('d')-60)+'/'+(date('m'))+'/'+(date('Y'))} which is displayed as -39/02/2018.

Any ideas? (I suck at PHP and java, so please don't suggest any of those)
The topic has been locked.
More
6 years 1 month ago #164384 by Deusdeorum
Replied by Deusdeorum on topic Date - 60 days (dynamic)
What format is ComissionDate? Is it a question?
The topic has been locked.
  • rbernhardthki
  • rbernhardthki's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 1 month ago #164385 by rbernhardthki
Replied by rbernhardthki on topic Date - 60 days (dynamic)
Commission date is a question in 'dd/mm/yyyy' format
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 1 month ago - 6 years 1 month ago #164386 by Joffm
Replied by Joffm on topic Date - 60 days (dynamic)
Hi,

Today: {date("Y-m-d")}
60 days ago: {date("Y-m-d",strtotime("-60 days"))}



Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 6 years 1 month ago by Joffm.
The following user(s) said Thank You: rbernhardthki
The topic has been locked.
  • rbernhardthki
  • rbernhardthki's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 1 month ago #164389 by rbernhardthki
Replied by rbernhardthki on topic Date - 60 days (dynamic)
Thank you! Works great
The topic has been locked.
  • rbernhardthki
  • rbernhardthki's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 1 month ago #164392 by rbernhardthki
Replied by rbernhardthki on topic Date - 60 days (dynamic)
One more thing. Do you also know how to use this validation to show a question?

Basically I need to show a question which will say: Sorry, not covered under warranty if the commission date is >= today-60

Thanks
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 1 month ago #164393 by Joffm
Replied by Joffm on topic Date - 60 days (dynamic)
Set Relevance of that question to

ComDate>date("Y-m-d",strtotime("-60 days"))

But is this correct?

Sorry, not covered under warranty if the commission date is >= today-60

If it is within the last 60 days it is NOT covered?

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
More
6 years 1 month ago - 6 years 1 month ago #164394 by Deusdeorum
Replied by Deusdeorum on topic Date - 60 days (dynamic)
Just use your same equation in the "relevance equation" of the question. It will be validated as a bool, so something like (ComissionDate >= date("Y-m-d",strtotime("-60 days"))) or however your equation ended up like !
Last edit: 6 years 1 month ago by Deusdeorum.
The topic has been locked.
  • rbernhardthki
  • rbernhardthki's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 1 month ago #164395 by rbernhardthki
Replied by rbernhardthki on topic Date - 60 days (dynamic)
My bad :) the > is the other way around

I did try to set the relevance but it is not working:

if(INSERTANS:669123X299X2380<=date('d/m/Y', strtotime("-60 days")),1,0)

Attachments:
The topic has been locked.
More
6 years 1 month ago #164396 by Deusdeorum
Replied by Deusdeorum on topic Date - 60 days (dynamic)
Try removing the if-statement, (INSERTANS:669123X299X2380<=date('d/m/Y', strtotime("-60 days")))
The topic has been locked.
  • rbernhardthki
  • rbernhardthki's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 1 month ago #164397 by rbernhardthki
Replied by rbernhardthki on topic Date - 60 days (dynamic)
Yes I realized, it is still showing the question no matter what date I enter.
Attachments:
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 1 month ago #164398 by tpartner
Replied by tpartner on topic Date - 60 days (dynamic)
Or convert it to epoch time. So, something like this for the relevance equation:

Code:
(strtotime(date("Y-m-d")) - strtotime(ComissionDate)) <= (60*60*24*60)

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose