LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

calculate days left until given date

Solved!
Go to solution

Hello

 

I'm facing a problem and can't get to a good solution.

I want to calculate how many days there are still left until a certain date.

This is because I want to build in a reminder to re-kalibrate the hardware that is used every year.

 

So if it's today 11-5-2012, and the constant is 21-05-2012 labview has to calculate there are still 10 days left before the re-kalibration has to be finished.

 

Anyone has got an idea how to make this?

 

Thanks in advantage!

 

 

0 Kudos
Message 1 of 4
(3,758 Views)
Solution
Accepted by topic author Patrick Kerstholt

sure, remember that time stamps are DBL in seconds.

 

Example_VI.png

 

Hope this helps


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

Message 2 of 4
(3,757 Views)

You can use formatting to control the presentation of a value. Leave the units as seconds and set the properties of the indicator to use relative time with a format of %<%D>t. The value on the wire will continue to be in seconds, but the front panel will display the equivelant number of whole days.

 

You can also apply units to simplify the readability of your code; but be aware that once you apply units to a control or indicator the units propogate  (down the wire) and that LabVIEW will check for incompatible units. This can sometimes lead to strange results or cause a sub-vi to report as broken without any obvious problem.

 

If you convert a unitless number to a specific physical group using Build Unit String and then convert it again to the same physical group with different units, the wire will revert to unitless but the value will be in the specified units. In the example below, the value for days would be whole days and fraction of a day.

 

http://thinkinging.com/2007/06/08/labview-tip-easy-relative-timestamp-calculations/

http://thinkinging.com/2007/06/25/labview-tip-easy-unit-conversion/

 

Relative Time.PNG

 

 

 


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

Message 3 of 4
(3,749 Views)

Example_VI.png

 

I'm just kidding.  I was playing around with SQLite date queries yesterday 😄

 

Spoiler
But, it works...  You can get the SQLite API here.

 

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 4 of 4
(3,740 Views)