04-16-2009 06:34 AM
Hi,
I am trying to create a vi that calculates the difference between two times (as generated by the Get Sate / Time String function).
Essentially my vi needs 5 inputs:
Start Time; Start Date; End Time; End Date; Want Seconds? (F).
It also needs 1 output:
Elapsed Time (String "YYYY/MM/DD|HH:MM:SS")
To do something like this I would need to program a calendar into a vi. This would be extremely time consuming and I was wondering if there was anything already out there that anyone knew of that could make my life a little simpler!?
Many thanks, Alec
Solved! Go to Solution.
04-16-2009 07:16 AM
Why would you need to program a calendar?
Maybe I didn't undestand what you want... I'll do a quick example of what I understood and you can comment on how far I was from the target...
R
04-16-2009 07:46 AM
04-16-2009 08:09 AM
Agreed Paul,
But what if the elapsed time goes beyond 1 month and you want to show the elapsed time as YYYY/MM/DD HH:MM:SS ?
Which actually does not make sense... because you would never represent delta time by a datestamp.
Is it okay to simply display delta time as:
(delta) days
(delta) hours
(delta) minutes
(delta) seconds
?
For the obvious reason that different months have different number of days and a delta time cannot point to a certain month because there is no calendar for delta time.
R
04-16-2009 08:16 AM
04-16-2009 11:58 AM
Alec,
See the attached example... Let us know if it waht you were looking for.
The example is an ActionEngine. Simply select "Start Time/Date" and run it. Later, select "Get elapsed time" to get the numebr of days / hours / minutes / seconds that have elapsed since the Start Time/Date was selected.
R
04-17-2009 04:16 AM
04-17-2009 06:54 AM
Glad to help.
You can clean up the example by removing unnecessary items such as the three items at the top (Start Date, Current Dat, seconds). I had left them in for "debug". You can then wire the control (enumerator) and indicators to the connector pane (top right below the icon). That will allow you to use the VI as an ActionEngine right into your own software.
If you plan to use the code into your existing code, you'll have to be careful on how you implement it. For instance you could take the initial start time(timestamp)at the appropriate location within your code andbring the wire to the appropriate location in your code where you would copy/paste the code within the "Get Elapsed Time" state.
R
03-28-2017 03:11 PM - edited 03-28-2017 03:14 PM
@Ray.R, I realize this is an old thread but wondering if you could clarify your last statement or provide an example of the usage? You wrote:
"... bring the wire to the appropriate location in your code where you would copy/paste the code within the "Get Elapsed Time" state."
I don't understand the copy/paste portion. Couldn't you wire the Enum to a connector? Then simply drop the VI where you need it, passing in the desired action via the Enum? Thanks!
Never mind! I got it!
03-28-2017 03:39 PM
The resetValues Enum state doesn't seem to reset the seconds field.