From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I'm having trouble with D4.1 in Labview '09. It says to determine someone's age in years, when given current month,day,and year, and the person's birth month, day and year

Solved!
Go to solution

Given someone's Birth month day and year....and also the current month day and year...as inputs....calculate their age, in years...as output....age should not increment by one until their birthday arrives that year.   I just cant get the coding right...please help

0 Kudos
Message 1 of 28
(3,713 Views)

What have you done so far? Show us what you tried and explain where it fails

 

What's "D4.1"?

 

The "Date/Time to Seconds" function will be helpful to you.

0 Kudos
Message 3 of 28
(3,694 Views)

Subtract the birth year from the current year (four digit format) to get preliminary age.  Then check the date (if current month/day is less  than birth month/day, subtract 1 from age). should only require a few math steps and a case structure.

0 Kudos
Message 4 of 28
(3,672 Views)

Just subtract the two date/timestamps.  Then round down to the year.

Message 5 of 28
(3,670 Views)

@nathand wrote:

[...] What's "D4.1"? [...]


That's the number of the homework assignment.

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 6 of 28
(3,661 Views)

thanks for your help...I'm new to lab view and am unfamiliar with a lot of the functions.  I was using a select function. If the current year > the birth yr, then Current-birth.  that worked.  but as i try to connect the months and days into it , thats where my issues are coming up...I'm still not getting the outcome i want. Thanks

 

0 Kudos
Message 7 of 28
(3,654 Views)

Subtract the years from each other than subtract 1 to get age

 

Then

 

If current month is greater than birth month then

  age=age+1

Elseif  current month is equal to birth month AND current day is greater than equal to birthday then

  age = age +1

Else

  age is what you got in the first step.

end if.

Message 8 of 28
(3,641 Views)

It's called a Case Structure.  It has an input terminal which you can wire.  one piece of code inside the structure runs base on the value wired to the input terminal.

0 Kudos
Message 10 of 28
(3,624 Views)