Auto generating age in years and months from Date of Birth

Hi Team members, I was creating a survey with Variables Date of Birth and Age. Is it possible to autogenarate Age in Years and Months from the date of birth entered?

Q3. Enter date of birth (dd/mm/yyyy): //_________

Q5. Current Age: Years:________________ Months:____________

Thanks

Collins

Yes its possible let me write the calculate function that you will need to put.

S. Aloo

···

On 8 May 2013 08:05, “Collins McAdoyo” collin...@gmail.com wrote:

Hi Team members, I was creating a survey with Variables Date of Birth and Age. Is it possible to autogenarate Age in Years and Months from the date of birth entered?

Q3. Enter date of birth (dd/mm/yyyy): //_________

Q5. Current Age: Years:________________ Months:____________

Thanks

Collins

You received this message because you are subscribed to the Google Groups “Kobo Users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to kobo-users+...@googlegroups.com.

To post to this group, send email to kobo-...@googlegroups.com.

Visit this group at http://groups.google.com/group/kobo-users?hl=en.

For more options, visit https://groups.google.com/groups/opt_out.

Yes, Stephen what’s is this calculate function I’ll need to put?

Collins

···

On Wed, May 8, 2013 at 8:39 AM, Aloo Stephen stepha...@gmail.com wrote:

Yes its possible let me write the calculate function that you will need to put.

S. Aloo

On 8 May 2013 08:05, “Collins McAdoyo” collin...@gmail.com wrote:

Hi Team members, I was creating a survey with Variables Date of Birth and Age. Is it possible to autogenarate Age in Years and Months from the date of birth entered?

Q3. Enter date of birth (dd/mm/yyyy): //_________

Q5. Current Age: Years:________________ Months:____________

Thanks

Collins


You received this message because you are subscribed to the Google Groups “Kobo Users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to kobo-users+...@googlegroups.com.

To post to this group, send email to kobo-...@googlegroups.com.
Visit this group at http://groups.google.com/group/kobo-users?hl=en.

For more options, visit https://groups.google.com/groups/opt_out.


You received this message because you are subscribed to the Google Groups “Kobo Users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to kobo-users+...@googlegroups.com.

To post to this group, send email to kobo-...@googlegroups.com.
Visit this group at http://groups.google.com/group/kobo-users?hl=en.

For more options, visit https://groups.google.com/groups/opt_out.

I have been on field when I get to my hotel room will write out the code and send it to you. Thanks

S. Aloo

···

On 8 May 2013 15:13, “Collins O. Adoyo” collin...@gmail.com wrote:

Yes, Stephen what’s is this calculate function I’ll need to put?

Collins

On Wed, May 8, 2013 at 8:39 AM, Aloo Stephen stepha...@gmail.com wrote:

Yes its possible let me write the calculate function that you will need to put.

S. Aloo

On 8 May 2013 08:05, “Collins McAdoyo” collin...@gmail.com wrote:

Hi Team members, I was creating a survey with Variables Date of Birth and Age. Is it possible to autogenarate Age in Years and Months from the date of birth entered?

Q3. Enter date of birth (dd/mm/yyyy): //_________

Q5. Current Age: Years:________________ Months:____________

Thanks

Collins


You received this message because you are subscribed to the Google Groups “Kobo Users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to kobo-users+...@googlegroups.com.

To post to this group, send email to kobo-...@googlegroups.com.
Visit this group at http://groups.google.com/group/kobo-users?hl=en.

For more options, visit https://groups.google.com/groups/opt_out.


You received this message because you are subscribed to the Google Groups “Kobo Users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to kobo-users+...@googlegroups.com.

To post to this group, send email to kobo-...@googlegroups.com.
Visit this group at http://groups.google.com/group/kobo-users?hl=en.

For more options, visit https://groups.google.com/groups/opt_out.

You received this message because you are subscribed to the Google Groups “Kobo Users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to kobo-users+...@googlegroups.com.

To post to this group, send email to kobo-...@googlegroups.com.

Visit this group at http://groups.google.com/group/kobo-users?hl=en.

For more options, visit https://groups.google.com/groups/opt_out.

Great, I’d like to see how you do it.

☞§※☼:airplane::open_umbrella::slight_smile:

~Neil

Hello Collins and Neil

Please paste this within your synax window.

<?xml version="1.0" encoding="UTF-8"?>

<h:html xmlns:jr=“http://openrosa.org/javarosa” xmlns=“http://www.w3.org/1999/xhtml” xmlns:h=“http://www.w3.org/1999/xhtml” xmlns:kobo=“http://www.kobotoolbox.org/xmlns” xmlns:xsd=“http://www.w3.org/2001/XMLSchema”>

<h:head>
<h:title ref=“jr:itext(‘Auto_Age’)”>Auto_Age</h:title>


<Auto_Age id=“Auto_Age”>

      <start/>
      <end/>
      <A01/>
      <A02/>
      <A033/>
      <A03/>
      <A04/>
      <A05/>
      <A06/>

      <A08/>
      </Auto_Age>
  </instance>
  <bind id="deviceid" nodeset="/Auto_Age/deviceid" type="xsd:string" jr:preload="property" jr:preloadParams="deviceid" visible="false()"/>

  <bind id="start" nodeset="/Auto_Age/start" type="xsd:time" jr:preload="timestamp" jr:preloadParams="start" visible="false()"/>
  <bind id="end" nodeset="/Auto_Age/end" type="xsd:time" jr:preload="timestamp" jr:preloadParams="end" visible="false()"/>

  <bind id="A01" nodeset="/Auto_Age/A01" type="xsd:date" required="true()"/>
  <bind id="A02" nodeset="/Auto_Age/A02" type="xsd:date" readonly="true()" required="true()"/>

  <bind id="A033" nodeset="/Auto_Age/A033" type="xsd:binary" required="true()"/>
  <bind id="A03" nodeset="/Auto_Age/A03" type="xsd:int" readonly="true()" calculate="(/Auto_Age/A02 - /Auto_Age/A01) * 0.0027397" visible="false()"/>

  <bind id="A04" nodeset="/Auto_Age/A04" type="xsd:int" readonly="true()" calculate="(/Auto_Age/A02 - /Auto_Age/A01) * 0.032894736842" visible="false()"/>

  <bind id="A05" nodeset="/Auto_Age/A05" type="xsd:string" readonly="true()" calculate="concat(/Auto_Age/A03)" visible="false()"/>
  <bind id="A06" nodeset="/Auto_Age/A06" type="xsd:int" readonly="true()" calculate="(/Auto_Age/A04 - (/Auto_Age/A05 * 12))" visible="false()"/>

  <bind id="A08" nodeset="/Auto_Age/A08" type="xsd:string" calculate="concat(/Auto_Age/A03,'Years ',/Auto_Age/A06,'Months')" required="true()"/>           

  <itext>
    <translation lang="English">
      <text id="Auto_Age">
        <value>Auto_Age</value>
      </text>
      <text id="A01">

        <value>Date of Birth</value>
      </text>
      <text id="A02">
        <value>Current Date (This will not change even if survey is reopened on a different date)</value>

      </text>
     <text id="A033">
        <value>THESE ARE AUTOCOMPUTED VALUES</value>
      </text>
      <text id="A03">
        <value>Age (Years)Stage 1</value>

      </text>
      <text id="A04">
        <value>Age (Months) Stage 2</value>
      </text>
      <text id="A05">
        <value>Years</value>

      </text>
      <text id="A06">
        <value>Months</value>
      </text>
      <text id="A08">
        <value>Age in Years and Months (ACKNOWLEDGE stepha...@gmail.com If interested I can be able to do more complex incorporation of functions for your surveys) </value>

      </text>
      </translation>
  </itext>
</model>

</h:head>
<h:body>

</input>
<input bind="A02">
  <label ref="jr:itext('A02')"/>
</input>
<group appearance="field-list" ref="A033">

  <label ref="jr:itext('A033')"/>
<input bind="A04">
  <label ref="jr:itext('A04')"/>
</input>
   <input bind="A05">
  <label ref="jr:itext('A05')"/>

</input>
<input bind="A06">
  <label ref="jr:itext('A06')"/>
</input>
</group>
<input bind="A08">
  <label ref="jr:itext('A08')"/>

</input>

</h:body>
</h:html>

Auto_Age.xml (3.67 KB)

···

On Wed, May 8, 2013 at 8:05 AM, Collins McAdoyo collin...@gmail.com wrote:

Hi Team members, I was creating a survey with Variables Date of Birth and Age. Is it possible to autogenarate Age in Years and Months from the date of birth entered?

Q3. Enter date of birth (dd/mm/yyyy): //_________

Q5. Current Age: Years:________________ Months:____________

Thanks

Collins

You received this message because you are subscribed to the Google Groups “Kobo Users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to kobo-users+...@googlegroups.com.

To post to this group, send email to kobo-...@googlegroups.com.

Visit this group at http://groups.google.com/group/kobo-users?hl=en.

For more options, visit https://groups.google.com/groups/opt_out.


Aloo Stephen Onuong’a
Public Health & Social Research Specialist
+254721260024

1 Like

Thanks Steve its working.

Collins

···

On Wed, May 8, 2013 at 8:05 AM, Collins McAdoyo collin...@gmail.com wrote:

Hi Team members, I was creating a survey with Variables Date of Birth and Age. Is it possible to autogenarate Age in Years and Months from the date of birth entered?

Q3. Enter date of birth (dd/mm/yyyy): //_________

Q5. Current Age: Years:________________ Months:____________

Thanks

Collins


You received this message because you are subscribed to the Google Groups “Kobo Users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to kobo-users+...@googlegroups.com.

To post to this group, send email to kobo-...@googlegroups.com.
Visit this group at http://groups.google.com/group/kobo-users?hl=en.

For more options, visit https://groups.google.com/groups/opt_out.

+254721260024

Aloo Stephen Onuong’a
Public Health & Social Research Specialist

This is Dynamite!

Steven, we’re always very impressed by your work, I wonder if you might like to post something about the use and methods of the Calculate function?
☞§※☼:airplane::open_umbrella::slight_smile:

~Neil

···

On Wed, May 8, 2013 at 8:05 AM, Collins McAdoyo collin...@gmail.com wrote:

Hi Team members, I was creating a survey with Variables Date of Birth and Age. Is it possible to autogenarate Age in Years and Months from the date of birth entered?

Q3. Enter date of birth (dd/mm/yyyy): //_________

Q5. Current Age: Years:________________ Months:____________

Thanks

Collins


You received this message because you are subscribed to the Google Groups “Kobo Users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to kobo-users+...@googlegroups.com.

To post to this group, send email to kobo-...@googlegroups.com.
Visit this group at http://groups.google.com/group/kobo-users?hl=en.

For more options, visit https://groups.google.com/groups/opt_out.

+254721260024

Aloo Stephen Onuong’a
Public Health & Social Research Specialist

Hello Neil

Will do so… I am currently working on a tool that is taking your KOBO to the greatest test limits so I will be able to document a lot based on this assignment with calculate function among other functions that I found could work with the sytem. So probably at a later stage. Thanks for the complement. On a lighter note since last year we are now implementing national level Study Number 11 using KOBO (teams have nicknamed the phones KOBO and call each other Koblets)

Aloo Stephen Onuong’a

···

On Wed, May 8, 2013 at 8:05 AM, Collins McAdoyo collin...@gmail.com wrote:

Hi Team members, I was creating a survey with Variables Date of Birth and Age. Is it possible to autogenarate Age in Years and Months from the date of birth entered?

Q3. Enter date of birth (dd/mm/yyyy): //_________

Q5. Current Age: Years:________________ Months:____________

Thanks

Collins


You received this message because you are subscribed to the Google Groups “Kobo Users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to kobo-users+...@googlegroups.com.

To post to this group, send email to kobo-...@googlegroups.com.
Visit this group at http://groups.google.com/group/kobo-users?hl=en.

For more options, visit https://groups.google.com/groups/opt_out.

+254721260024

Aloo Stephen Onuong’a
Public Health & Social Research Specialist

Fantastic! Do please let us know more about your study, I’ll add something to the user showcases for you. We often call eachother “KoBoNauts”

☞§※☼:airplane::open_umbrella::slight_smile:

~Neil

···

On Wed, May 8, 2013 at 8:05 AM, Collins McAdoyo collin...@gmail.com wrote:

Hi Team members, I was creating a survey with Variables Date of Birth and Age. Is it possible to autogenarate Age in Years and Months from the date of birth entered?

Q3. Enter date of birth (dd/mm/yyyy): //_________

Q5. Current Age: Years:________________ Months:____________

Thanks

Collins


You received this message because you are subscribed to the Google Groups “Kobo Users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to kobo-users+...@googlegroups.com.

To post to this group, send email to kobo-...@googlegroups.com.
Visit this group at http://groups.google.com/group/kobo-users?hl=en.

For more options, visit https://groups.google.com/groups/opt_out.

+254721260024

Aloo Stephen Onuong’a
Public Health & Social Research Specialist

Hi
I need to make the phone number be eleven digits not increase not decrease

Hi you can use this in constraints field:
regex(.,’[0-9]{11}’)

@moteb_marei Please see my recent posting Number constraints - #6 by Xiphware as to why this regex is incorrect.

@ziyad Could you please remember to open a new thread topic for new questions, this is rather unrelated to the original topic. Or if you want to email another forum member directly you can use the Flag control to send them a private message.

Hi,

But if you make the type of question integer nobody will be able to write string entries

Best Regards

Moteb Marei

Please note that using an integer question to enter phone numbers is problematic due to the limited number of digits allowed (max 9), which may well be insufficient to store a long phone number. It is therefore recommended - for phone numbers - to use a regular text widget (which effectively has unlimited length) with an appearance=“numbers”. But this is basically only a hint to the XForm client to display a keyboard that only permits entering numbers, which depending on your platform may or may not be possible (eg Enketo cant control your laptops keyboard…). So in addition it is also recommended to add a suitable constraint regex (see above) to ensure that the user only submits numbers.

if still suffering from that can you try this:
regex (.,’^[A-Za-z0-9._؟?#&*/@;:؛÷×%$ ±]
{11} $’)

Good grief! What ARE you trying to match!?! :slight_smile:

But seriously, what sort of user input data are you trying to validate, and in what way is your regex above misbehaving? Perhaps give a couple of example of strings that you want to match, and I’m sure we can come up with a suitable regex.

Sorry I didn’t understand what you meant exactly:
But in my work we are using ID entering for beneficiaries to avoid duplicating in names … to match assessment data with distribution data:
ID number is unique for all citizens and consists from 11 numbers… so in above regex i force enumerators to add only number with “text” type of question… we have 2 languages Arabic and English… Some times they are laptops to fill data into server

Unfortunately, multi-lingual regexs are beyond my scope of expertise (I don’t even know if you can do them). Perhaps someone else here who has successfully implemented constraint checking against non-English text input can provide some insight?

Yes Dear we are using Arabic Language mainly but the form in English as you know, So to prevent people making mistake I did that regex.