LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

date of birth to age

does anyone know how to calculate a person's age from his date of birth?

any examples are welcome 🙂

 

thanks!

0 Kudos
Message 1 of 12
(8,111 Views)

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

0 Kudos
Message 2 of 12
(8,098 Views)
This will give an answer, but it's not all of what you want.  What format do you want?  Years/months/days/hours/minutes/seconds?  Years as a double?  Seconds?

Example_VI_BD.png
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 3 of 12
(8,095 Views)

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?

0 Kudos
Message 4 of 12
(8,093 Views)

@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

0 Kudos
Message 5 of 12
(8,092 Views)

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

0 Kudos
Message 6 of 12
(8,075 Views)
By any chance, is this a school project?

Paul
0 Kudos
Message 7 of 12
(8,057 Views)
I don't need to send you the VI, it's right there as a VI Snippet.  All of the functions are in the Timing pallet if you need to make it yourself.
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 8 of 12
(8,008 Views)

ok thanks!

0 Kudos
Message 9 of 12
(7,993 Views)

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 .

 

0 Kudos
Message 10 of 12
(7,019 Views)