Willkommen, Gast Benutzername: Passwort: Angemeldet bleiben:

## Calculating age at a certain date 1 Jahr 11 Monate her #96089

 ahchouch OFFLINE Junior Lime Beiträge: 22 Karma: 0 Hi Everybody It's my first use of Limesurvey and I know nothing about Javascript!! I have a question group including these question: Q1: date question (dd/mm/yyyy): date of birth Q2; date question : date of hospitalization Q3: date question : date of intervention I need to calculate age (in the same group) at the intervention date (DOB - DOI: in years) I also need to verify before that: the hospitalization date is >= to the DOB the intervention date is >= to the hospitalization date If one of these condition is not OK an alert should be given (according to the unsatisfied condition)and the age wouldn't be calculated than. Please I need help!! Der Administrator hat öffentliche Schreibrechte deaktiviert.

## Calculating age at a certain date 1 Jahr 11 Monate her #96090

 Ben_V OFFLINE Platinum Lime Beiträge: 1292 Dank erhalten: 303 Karma: 86 Hello, A part of expected responses to your questions can be found here The topic teach how to calculate age (in an equation type question) from dob... or from any retrieved date 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... Der Administrator hat öffentliche Schreibrechte deaktiviert.

## Calculating age at a certain date 1 Jahr 11 Monate her #96108

• ahchouch
• Junior Lime
• Beiträge: 22
• Karma: 0
Thanks Ben
I've alredy had a look at that and tried it. It works with today date as differential of DOB, but when I replace it with the DOI (date of intervention) it doesn't work.
I guess it has something to do with the listener :\$('#answer48427X164X1612').change(function() {
I don't know if it has to be changed (and how) to listen to the change of the tow dates (DOB and DOI).
What do you think about it?
I attach the group question ( I added the second question value to the change listener!)
Could tell me what's wrong?

#### Dateianhang:

Dateiname: limesurvey_group_35.lsg
Dateigröße: 5 KB

To compare dates I found this:http://www.limesurvey.org/fr/forum/can-i-do-this-with-limesurvey/93224-validating-dates
Again I don't know how to combine all this to do do all the job (comparing dates and calculating age!)

## Calculating age at a certain date 1 Jahr 11 Monate her #96114

 ahchouch OFFLINE Junior Lime Beiträge: 22 Karma: 0 It's OK. There were extra quotes (') in the listener part. Now it works fine to calculate age. Could someone help me with integrating the comparing dates script to it. Thanks Der Administrator hat öffentliche Schreibrechte deaktiviert.

## Calculating age at a certain date 1 Jahr 11 Monate her #96115

 Ben_V OFFLINE Platinum Lime Beiträge: 1292 Dank erhalten: 303 Karma: 86 The problem is to adapt this code to use the date at intervention instead the current date. It looks possible and I'll make some try when I get a bit more time but if I don't start very confident because I used to face issues when manipulating dates For your other questions maybe you can calculate the number of days between the 2 dates and if the returned value is negative, an alert may be displayed 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... Der Administrator hat öffentliche Schreibrechte deaktiviert.

## Calculating age at a certain date 1 Jahr 11 Monate her #96116

 Ben_V OFFLINE Platinum Lime Beiträge: 1292 Dank erhalten: 303 Karma: 86 More resource: 1) external 2) Doc (webcache google) (search for "Calculating date difference" at the end) 3) sample survey (if you can install it...) 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... Der Administrator hat öffentliche Schreibrechte deaktiviert.

## Calculating age at a certain date 1 Jahr 11 Monate her #96182

• ahchouch
• Junior Lime
• Beiträge: 22
• Karma: 0
thank you Ben.
I actually used the script as in the attached example. For comparing dates and getting alerts, simple (if condition) were sufficiant.
here's the group with the three date questions (dob, doi, doh) and the age calculation.

#### Dateianhang:

Dateiname: limesurvey_group_2.lsg
Dateigröße: 9 KB

## Calculating age at a certain date 1 Jahr 10 Monate her #96261

 ahchouch OFFLINE Junior Lime Beiträge: 22 Karma: 0 Hi When I try to compare dates that aren't on the same page, it doesn't work. I think it's a problem of reference to the date that isn't on the current page. I don't know how to refer to it. Seems it's not possible with JS? How could I than calculate difference and get alerts i_n that case? Any ideas! Der Administrator hat öffentliche Schreibrechte deaktiviert.
Moderatoren: ITEd