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

You've got case structures,

you've got select statements.

 

Either one will behave like an "if statement"

Message 11 of 28
(1,366 Views)

Yes - there is the case structure, and the select function. But this seems like a purely mathematical operation, I'm not sure an if is necessary. You still haven't uploaded any code to show us what you've tried.

 

Timestamps in LabVIEW are represented as a number of seconds since some absolute date. You can convert the birth date into that format (using Date/Time to Seconds). Subtract from the current date, divide by the number of seconds in a year, round appropriately. If you want to be really precise about it you'll need to deal with leap years, but I'd guess it's sufficient to approximate it by adding one quarter of a day to the number of seconds in a year.

0 Kudos
Message 12 of 28
(1,362 Views)

My thinking was along the lines as nathand.  Subtract time stamps and use the Quotient and Remainder to divide by the number of seconds in a year.  The quotient will be the age in years.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 14 of 28
(1,352 Views)

I'm not sure where you pulled the Build Cluster Array from.  That function has nothing to due with your problem.  Look in the Timing palette and find the Date/Time to Seconds function.  Right-click on the date/time rec input and create a constant.  Delete the wire.  Now use Bundle By Name to replace the Year, Day, and Month in the cluster.  Wire the new cluster into the Date/Time to Seconds function.  This will give you a proper time stamp.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 15 of 28
(1,346 Views)

You might want to spend some time going through LabVIEW basics and tutorials. Why did you pick "Build Cluster Array"?

 

Start with Date/Time to Seconds, as I suggested in a previous post. Create a constant, or a control, for the Data/Time Rec input.

Message 16 of 28
(1,344 Views)

Right idea, but why are you bundling month, day and year into the "fractional second" element instead of the month, day, and year elements?

Message 18 of 28
(1,326 Views)

I see the inputs now...but if you run my VI,  it is still not working properly. I know I'm missing something.  I appreciate your patience.  I've only been using Labview for a few days.

0 Kudos
Message 19 of 28
(1,319 Views)