- Posts: 45
- Thank you received: 7
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
date calculation with relevance equation problem
- jboogie21
- Topic Author
- Offline
- Senior Member
Less
More
8 years 11 months ago #118511
by jboogie21
date calculation with relevance equation problem was created by jboogie21
I'm using this code to determine whether or not a group of questions should be displayed:
The desired function is to display a group of questions if the calculated age based on a birthdate in the token table in the format mm/dd/yyyy is <= 5.
What I discovered is that for the equation to calculate correctly, the birthdate has to be at least 2 days from the time the survey was started for the equation to work. For example, I start the survey today (i.e. 3/20/2015), the token field birthdate has to be at least 3/22/2010 before the calculation meets the condition and shows the group of questions for <=5. This does not seem right, as the child's birthday is 3/21/2010 and I start the survey on 3/20/2015 I should still get the questions for the <=5 people as I don't turn 5 until the following day (3/21/2015) from when I started the survey.
I imagine this might be a number formatting/round issues. Has anyone experienced this or can provide any guidance?
The desired function is to display a group of questions if the calculated age based on a birthdate in the token table in the format mm/dd/yyyy is <= 5.
What I discovered is that for the equation to calculate correctly, the birthdate has to be at least 2 days from the time the survey was started for the equation to work. For example, I start the survey today (i.e. 3/20/2015), the token field birthdate has to be at least 3/22/2010 before the calculation meets the condition and shows the group of questions for <=5. This does not seem right, as the child's birthday is 3/21/2010 and I start the survey on 3/20/2015 I should still get the questions for the <=5 people as I don't turn 5 until the following day (3/21/2015) from when I started the survey.
I imagine this might be a number formatting/round issues. Has anyone experienced this or can provide any guidance?
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11746
- Thank you received: 2750
8 years 11 months ago #118518
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic date calculation with relevance equation problem
I would guess that there have been 2 leap years within the last 5 years, which would explain the 2 days difference, wouldn't it?
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
8 years 11 months ago - 8 years 11 months ago #118526
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic date calculation with relevance equation problem
You can use this to get an accurate timestamp of 5 years before today:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 8 years 11 months ago by tpartner.
The topic has been locked.
- jboogie21
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 45
- Thank you received: 7
8 years 11 months ago #118567
by jboogie21
Replied by jboogie21 on topic date calculation with relevance equation problem
Ahh leap years. That makes sense. Also, thanks Tony for the tip! I'll try that.
The topic has been locked.