LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to calculate the number of days until your next birthday. Only using current month, day and birth month and day.

I'm trying to calculate the number of days until your next birthday. Only using current month, day and birth month and day. I can get close but i'm way off. When i enter in the next day, the amount of days is supposed to be 364. This is where I am having problems. I know my code is way off. I just need some guidance please!

0 Kudos
Message 1 of 6
(5,157 Views)

First off, if it was me, I wouldn`t have the user type in the current values - I would read the current time stamp and first set the hours, minutes and seconds to reflect midnight. Then turn that modified time stamp into a floating point number of second.

 

Take a branch of the modified time stamp wire and replace the month and day values with the birthday month and day. and convert the result of that operation into a floating point number of seconds.

 

Subtract the current number of seconds from the birthday number of seconds to get the number of seconds until the birthday.

 

Finally use LabVIEW units to convert seconds into days.

 

Mike....

 

PS: Extra points for modifiying this to compensate for birthdays that have already passed....


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 2 of 6
(5,150 Views)

I just had a little fun with the Time Record...


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 3 of 6
(5,147 Views)

I'm working on the same kind of problem. The only thing I am not understanding is why when I highlight the execution it is always 365 days.

0 Kudos
Message 4 of 6
(4,262 Views)

@Tnorm007 wrote:

I'm working on the same kind of problem. The only thing I am not understanding is why when I highlight the execution it is always 365 days.


I cannot look at your code right now, but if things change when you turn on highlight execution then you probably have race conditions due to local variables.  For something this simple, you should not need local variables.


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
0 Kudos
Message 5 of 6
(4,255 Views)

The order in your cluster does not match the order in the date time rec cluster.  So the subtraction is failing.  You can tell because your cluster shows coercion dots when you convert to seconds then subtract.

 

Delete your cluster control.  and all the wires coming coming out of the bundle by name.  Right click on the Date/Time to Seconds function input and create constant.  Now you'll have the cluster as a typedef in the correct order.  Now use that and complete the writing the example.

 

You can also drag the image in that message to your desktop and drag that to your block diagram.  it is a VI snippet and will automatically convert to code.

 

 

Message 6 of 6
(4,252 Views)