Welcome to the LimeSurvey Community Forum

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

Date - 60 days (dynamic)

More
7 years 6 months ago #164380 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
7 years 6 months 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.
More
7 years 6 months ago #164385 by rbernhardthki
Commission date is a question in 'dd/mm/yyyy' format
The topic has been locked.
More
7 years 6 months ago - 7 years 6 months 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: 7 years 6 months ago by Joffm.
The following user(s) said Thank You: rbernhardthki
The topic has been locked.
More
7 years 6 months ago #164389 by rbernhardthki
Thank you! Works great
The topic has been locked.
More
7 years 6 months ago #164392 by rbernhardthki
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.
More
7 years 6 months 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
7 years 6 months ago - 7 years 6 months 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: 7 years 6 months ago by Deusdeorum.
The topic has been locked.
More
7 years 6 months ago #164395 by rbernhardthki
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)

The topic has been locked.
More
7 years 6 months 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.
More
7 years 6 months ago #164397 by rbernhardthki
Yes I realized, it is still showing the question no matter what date I enter.
The topic has been locked.
More
7 years 6 months 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.
More
7 years 6 months ago #164400 by tpartner
Replied by tpartner on topic Date - 60 days (dynamic)
...sample survey attached:

File Attachment:

File Name: limesurvey...2633.lss
File Size:12.97 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
7 years 6 months ago #164401 by rbernhardthki
Thanks, dont know how to view samples. I will try to convert to epoch
The topic has been locked.
More
7 years 6 months ago #164402 by tpartner
Replied by tpartner on topic Date - 60 days (dynamic)
Just import the survey.

Cheers,
Tony Partner

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

Lime-years ahead

Online-surveys for every purse and purpose