LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calculate End of Test date/time. Live.

Solved!
Go to solution

Hello everyone!

Ok I have VI for my test rig that I can send out an email daily to update the status of the test. 

A few pieces of information such as percent complete and total elapsed time of the test are included. 

I want to include "End Date and Time" of the test as well. 

I use local variable strings as my data source that's compiled into the email. So the output of my question must be a string. 


An example is as follows. 

Lets say my test has a duration of 240 hours, with a start time of 6am. 9/15/2018

The next day at 6am when my email goes out, I would like it to include "Test Completion date-9/25/2018 at 6:00am"

Or something close to that format. 

If the test doesn't fault, day two will send out the exact same day time as another 24 hours has elapsed. 

 

But in the event a test does fault, and is delayed that will be show in the daily email update. 

This will be beneficial in my program managing and DVPR maintenance I handle. 

 

What I have been able to figure out is, take the hours and multiple by 3600 to get total seconds of test and convert that to time left. Weeks/days/hours/seconds or whatever output I want. 
But what I don't know how is to get that to convert to a future date that will update daily with the current date/time as it's "constant-dynamic". I know that doesn't make sense. I'm sure you know what I mean.

 

I've tried taking the total seconds and subtract that from the elapsed time and formatted that into what I've described above. 

I tried taking a time stamp and adding that to that output and getting my future date. Which technically worked, but it wasn't formatted as a string, so I was unable to use it....and the time stamp function I used was static, meaning it only took the date time from "zero" start time. If the test faulted, the end date wouldn't change. 

 

Hopefully that's clear as mud and someone has some elegant and easy method to accomplish this!

Thanks very much! 

Ryan

0 Kudos
Message 1 of 5
(2,971 Views)

Your wish is fulfilled -- it is clear as mud!  So I'm going to (I hope) help you find the answer for yourself.

 

You probably know that LabVIEW records time as "seconds since the Epoch Date/Time" (which you don't need to worry about for this).

 

This Snippet shows that if you take your start time and add 10 days worth of seconds to it, you'll get your end time.  Similarly, if you take two time stamps and subtract them, the difference will be in seconds, which (by clever math) you can convert to days, hours, minutes, and seconds (it gets messier if you want to add months and years).

Ten days later.png

You should be able to cobble this together on your PC.  The first item is a TimeStamp constant that I filled in with your chosen Date and Time.  The computation is 10 days in seconds (from the top, seconds/minute, minutes/hour, hours/day, and # days).  If you run this, you'll see the date and time for Ten days later.

 

I hope this gives you insights into the computations you'll need to "do what you want".

 

Bob Schor

0 Kudos
Message 2 of 5
(2,966 Views)

Thank you for this, however, that's pretty much what I've already figured out. 

The problem with this solution is that date constant, has to always change to "now". 

Meaning, if it were to send this morning, it would have to update to 9/16, tomorrow, 9/17 etc. 

Which I know how to get that function. 

Also, I need it to first calculate the remaining time of the test so it accurately gives the true end date. 

Again, I figured out how to get that, in seconds anyway. And I am able to spit out the "remaining time of the test" BUT I can't get it to convert all that into a future date. 

 

 

Also, the output has to be in a string as that is what my email-er is built from. 

All the inputs are strings, and that output won't give me a string. 

 

So-

1-Calculate total test time in seconds-COMPLETE (200 hours x 3600= 720,000 seconds)

2-GET current test time completed-COMPLETE (simple wire from the "total accumulated test hours say 100 hours that will give me 360,000 seconds)

3-Calculate the difference of the 2-COMPLETE (360,000 seconds remaining)

4-ADD step 3 to CURRENT or COMPUTER (to make it clearer) date.-UNKNOWN! 

 

The idea/point of this is lets say the test faults, or is paused for some reason. Actual test time is lost and that future date will need to be pushed out. 

 

Thank you

Ryan

0 Kudos
Message 3 of 5
(2,928 Views)
Solution
Accepted by topic author ryan1776

Look on the timing palette 

Right there you can find Format date time and get date and time.

 

Look on the string pallet and you will find date time to string with a format specified input.

 

Look on the property editor for any numeric and look at the advanced format page.  Time format specified are shown. They are also explained in the help file.


"Should be" isn't "Is" -Jay
Message 4 of 5
(2,920 Views)

Excellent. Thank you! 

0 Kudos
Message 5 of 5
(2,883 Views)