Calculate age from input date. - InfoPath Dev
in

InfoPath Dev

Calculate age from input date.

Last post 06-28-2010 12:04 PM by MikeW. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 01-25-2006 01:59 PM

    • BrownR
    • Top 200 Contributor
    • Joined on 08-14-2004
    • USA
    • Posts 54

    Calculate age from input date.

    Hello all,
    I'm working on a text box that calculates an age from a date Picker. I want the person to be able to input a date in a Date Picker and automatically calculate the personas age and display it in a text box. The only information that i could find was this one, http://blogs.msdn.com/infopath/archive/2005/01/25/360318.aspx

    The BLOG does exactlly what i want but im having a heck of a time trying to code it, anotherwords I cant get it to work. Any help is appriciated.
  • 01-25-2006 02:12 PM In reply to

    Re: Calculate age from input date.

    That blog is an awesome resource for what you're trying to accomplish. Could you post the code that you've written so far so we can see where your problems are and get you going in the right direction?

    ---------------
    Matt Faus
    InfoPath Dev Texas
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 07-26-2006 07:35 AM In reply to

    Re: Calculate age from input date.

    much much easier way to do this (in my humble opinion). Cut and paste this formula into the default value of the control to store the age.

    floor((number(substring(today(), 1, 4)) + number(substring(today(), 6, 2)) / 12 + number(substring(today(), 9, 2)) / 365.25) - (number(substring(@DOB, 1, 4)) + number(substring(@DOB, 6, 2)) / 12 + number(substring(@DOB, 9, 2)) / 365.25))

    Change the @DOB to the field which contains the date of birth.
  • 08-22-2006 12:15 PM In reply to

    • BrownR
    • Top 200 Contributor
    • Joined on 08-14-2004
    • USA
    • Posts 54

    Re: Calculate age from input date.

    quote:
    Originally posted by trufooser
    Change the @DOB to the field which contains the date of birth.



    trufooser,
    Thank you for that post. Its just what I needed, and didnt even have to change the data field. One more tool to add to my chest!
  • 05-27-2010 11:53 AM In reply to

    Re: Calculate age from input date.

    I have a form that has a data connection to a MS Access database and the fields are binded to a Birthdate field and a Age field.  I copy and pasted the above formula in the age field and verified it with no errors.  When I preview the form I get a NaN message in the age field.  Wondering what I'm doing wrong here.  Just trying to calculate the age of my patients.  Thank you.

     

     

  • 06-28-2010 12:04 PM In reply to

    • MikeW
    • Not Ranked
    • Joined on 06-09-2010
    • Posts 3

    Re: Calculate age from input date.

     

    Hi.....I found your post now dated 4 years ago.....a simple solution which I need but I get a NaN return.  The date of birth is read from a database as the form loads........any suggestions appreciated.  Am using 2007

     

    Thanks

     

    Mike

Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.