04-11-2010 04:54 PM
does anyone know how to calculate a person's age from his date of birth?
any examples are welcome 🙂
thanks!
04-11-2010 05:37 PM
In a general sense, you just get the current time as a time stamp, convert the date of birth to a time stamp, subtract, and there is the age. Again, you will want to use some of the time conversion functions to choose how to display the result, since timestamp units will not be useful to any person looking at the result.
BJ
04-11-2010 05:45 PM
04-11-2010 05:51 PM
i thought about substracting the two time stamps. the result would be the amount of seconds that have passed since the person was born.
to get from seconds to years, i could just divide the result by the amount of seconds in one year.
the problem is the fact that some years have 366 days instead of 365 days.
i could just add 1/4 times the amount of seconds in one day (as this occurs every four years), but that would be inaccurate.
any ideas?
04-11-2010 05:54 PM
@jcarmody
the format i want is the date of birth in dd/mm/yyyy and the age in years.
could you please send me that vi?
my email is lotte1990[at]gmail[dot]com
04-11-2010 06:07 PM
There is another way to go entirely. Use a normal numerical control (ie, a dbl) for the birthdate. You can select a custom date formatting for the numeric control that will display the value as mm/dd/yyyy (this comes from right clicking on the control and selecting the formatting option from the popup). Get the current time in seconds, subtract (you are still in seconds), and display that in a standard numeric indicator, again with the special time formatting applied. This handles leap years, as the time in seconds is understood by LabVIEW properly. Play around.
BJ
04-11-2010 10:16 PM
04-12-2010 07:22 AM
04-12-2010 08:24 AM
ok thanks!
03-01-2013 11:55 AM
Hi
Thanks
It works for me , but shows me negative value for months and days, funny .
and is it possible to seprate the data? for example I want to show the messge if the year is greater than 25 .