06-06-2014 01:35 PM
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!
06-06-2014 01:49 PM
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....
06-06-2014 01:57 PM - edited 06-06-2014 01:58 PM
I just had a little fun with the Time Record...
07-17-2017 08:25 PM
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.
07-17-2017 09:00 PM
@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.
07-17-2017 09:05 PM
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.