# Calculating age from date of birth

Dear Sirs et Madames,
I am trying to calculate a survey participants age through his/her
given date of birth. I have attempted to do this as follows:

``````                    <bind nodeset="dob" required="true()"
``````

constraint=". <= today()" type="date"/>
<bind nodeset="age" required="true()" type="int" calculate="today()

• ../dob" />

...
...

``````           <trigger ref="/sero-survey1/ageConfirmation">
<label>Acknowledge that participant is <output
``````

value="/sero-survey1/age"/> years old and is ?
...
...

However with a dob of Nov 4th 2004, this gives me an unrealistic age
of 2556. Could anyone tell me where I have gone wrong or how to
calculate age from dob in an XPath expression?

Thanks in advance,
Tumaini

try this age estimator. http://pastie.org/2813174

··· On Fri, Nov 4, 2011 at 14:54, Tumaini Kilimba wrote: > Dear Sirs et Madames, > I am trying to calculate a survey participants age through his/her > given date of birth. I have attempted to do this as follows: > > constraint=". <= today()" type="date"/> > > > ... > ... > > > Acknowledge that participant is value="/sero-survey1/age"/> years old and is ? > ... > ... > > However with a dob of Nov 4th 2004, this gives me an unrealistic age > of 2556. Could anyone tell me where I have gone wrong or how to > calculate age from dob in an XPath expression? > > Thanks in advance, > Tumaini > > -- > Post: opendatakit@googlegroups.com > Unsubscribe: opendatakit+unsubscribe@googlegroups.com > Options: http://groups.google.com/group/opendatakit?hl=en >