LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Subtracting time

Solved!
Go to solution

In my program I want to email the save file from the previous hour (this is because my file stays open and gets more info during the current hour). I have the date format as \%m%d%y_%H and didn't know how to change it to that format but one hour prior?

Thank you!

Let me know if you need more info

0 Kudos
Message 1 of 6
(4,820 Views)
Solution
Accepted by topic author Amanda_Kay

If you are using a timestamp value, subtract 3600.

Example_VI.png

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 2 of 6
(4,810 Views)
Solution
Accepted by topic author Amanda_Kay

Just subtract 3600 (number of seconds in an hour) from your current time.


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
(4,807 Views)

I have one more question, how would I put that in a case structure that will run only hourly. Is the "Wait(ms)" function the way to go?

0 Kudos
Message 4 of 6
(4,786 Views)
Solution
Accepted by topic author Amanda_Kay

Using the Wait (ms) function for such a long wait time is not a good idea. What if your program needs to stop early, before the hour is up? There is no way to stop the wait. Instead, you should write logic to check what time you started waiting and see if an hour has passed in a loop.

 

EveryHour.png

 

Here is an example of how to do this. I've put an event structure in to show you how you can respond to other events while you are waiting, such as the need to stop early.

Message 5 of 6
(4,766 Views)

I just found that you can also use time-units in arithmetic with timestamps, for example:

Time Stamp Arithmetic.png

So you don't need to work out how many second it is.

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