Page:123

Calculate age in an Equation type question, using Date of Birth 2 years 8 months ago #84792

 tfj OFFLINE Expert Lime Posts: 80 Thank you received: 6 Karma: 5 Greetings: Has anyone calculated a person's age in a Equation type question, using the Date of Birth from a previous question? I have been doing this with a MySQL query, but I would like to move it to LimeSurvey. I am using 1.92+ build 120808 on a Windows test PC. Thanks! tfj The administrator has disabled public write access.

Re: Calculate age in an Equation type question, using Date of Birth 2 years 8 months ago #84806

 DenisChenu NOW ONLINE Moderator Lime Posts: 7058 Thank you received: 948 Karma: 282 Hello, There a lot of script in web to do this, www.google.com/search?q=javascript+birth+age+calculation Need little adaptation for LS date. Denis Assistance on LimeSurvey forum and LimeSurvey core developpement are on my free time (Say thanks ?). A bug not reported is a bug not corrected. | Please, read the documentation | La doc en français à besoin de vous Official LimeSurvey Partner | Web development | SkeletonQuest, RWD for LimeSurvey The administrator has disabled public write access.

Re: Calculate age in an Equation type question, using Date of Birth 2 years 8 months ago #84826

 DenisChenu NOW ONLINE Moderator Lime Posts: 7058 Thank you received: 948 Karma: 282 Hello, I don't know if EM can work. But, with javascript: First make a date with a date question, if you format is dd-mm-yy then: Something like that to put the age in QQ: ``````If date of birth is in the same page, the a`\$("#questionQDATEOFBIRTHnumber input.date").blur(function(){AgeFromBirth(\$(this).val(),212);});`ca do the tric. And put this function with workarounds help: docs.limesurvey.org/tiki-index.php?page=..._etc._in_LimeSurvey_ Denis, PS: there are surely some error in javascript code, i make it directly in the forum PS2: calculation was taken here: pankajlalwani.wordpress.com/2010/08/02/a...ng-javascriptjquery/ Assistance on LimeSurvey forum and LimeSurvey core developpement are on my free time (Say thanks ?). A bug not reported is a bug not corrected. | Please, read the documentation | La doc en français à besoin de vous Official LimeSurvey Partner | Web development | SkeletonQuest, RWD for LimeSurvey The administrator has disabled public write access.

Re: Calculate age in an Equation type question, using Date of Birth 2 years 8 months ago #84828

 tfj OFFLINE Expert Lime Posts: 80 Thank you received: 6 Karma: 5 Denis: Thank you for taking the time out to help! I'll work on the example you provided . . . at least I know now that I was going down the wrong path with Expression Manager . . . Thanks again! tfj The administrator has disabled public write access.

Re: Calculate age in an Equation type question, using Date of Birth 2 years 8 months ago #84831

 Ben_V NOW ONLINE Platinum Lime Posts: 1305 Thank you received: 305 Karma: 87 In this thread it seems that some LS users did it... Ben/ Benoît goo.gl/Bw5iM => Recherche GG dans le forum français (remplacer "exemple" dans la barre de recherche) goo.gl/WX8PH => GG search for english forum (Replace "example" in the search bar) goo.gl/IxiGu => Búsqueda en el foro en español (Cambiar "ejemplo" en la barra de... Last Edit: 2 years 8 months ago by Ben_V. The administrator has disabled public write access.

Re: Calculate age in an Equation type question, using Date of Birth 2 years 8 months ago #84832

 tfj OFFLINE Expert Lime Posts: 80 Thank you received: 6 Karma: 5 benitov: Thanks for pointing me to this thread. This will also be helpful! tfj The administrator has disabled public write access.

Re: Calculate age in an Equation type question, using Date of Birth 2 years 8 months ago #84833

• Ben_V
• Platinum Lime
• Posts: 1305
• Karma: 87
I've tried the 2nd code given on the thread using a date question type (with format dd.mm.yyyy) + a short-text question.... (both questions on the same page)
Everything is working fine with LS 1.90 but turned wrong with 1.92...
I don't know why...

File Attachment:

File Name: limesurvey_group_164.lsg
File Size: 8 KB

Re: Calculate age in an Equation type question, using Date of Birth 2 years 8 months ago #84836

• tpartner
• LimeSurvey Team
• Posts: 4728
• Karma: 410
Ben, it worked fine for me in 1.92. Maybe your IDs were wrong?

Here it is with more generic selectors to avoid the export-import/ID-change problem. The age value is simply loaded into the first short-text found.

File Attachment:

File Name: limesurvey_group_1324.lsg
File Size: 10 KB

Re: Calculate age in an Equation type question, using Date of Birth 2 years 8 months ago #84837

 tfj OFFLINE Expert Lime Posts: 80 Thank you received: 6 Karma: 5 Thanks, tpartner! I get a "NaN" error in the age text box. On the off chance that it had something to do with the date format -- since I use "mm-dd-yyyy" -- I changed this setting to "dd-mm-yyyy" for the survey and I still got the "NaN" error. In the meantime, I changed it back to "mm-dd-yyyy." This is another of those times where I figure I am missing something simple. tfj The administrator has disabled public write access.
 Page:123
Moderators: ITEd
Time to create page: 0.135 seconds