02-21-2018 02:20 PM
Hi folks,
i'm a little stumped with my 'Simple Elapsed Timer'.
The timer rolls over at 23:59:59 but what I need is to roll over at 999:59:59 (hhh:mm:ss).
I appreciate I can use %D for days but the graphical data needs to be presented as 100's hours v process variable.
Can anybody offer any suggestions
Regards and tia
%H:%M:%S%1u
Solved! Go to Solution.
02-21-2018 02:32 PM
02-21-2018 02:35 PM
02-22-2018 12:02 AM - edited 02-22-2018 12:17 AM
Simon,
It may be instructive here to discuss the concepts within LabVIEW of absolute time (when did this happen?) versus relative time (for how long did this happen?). The LabVIEW timestamp datatype always represents an absolute point in time in the LabVIEW epoch, unambiguously referenced to UTC. Arithmetic operations with timestamps are properly limited to addition (adding a relative offset to a timestamp) and subtraction (how much relative time passed between two timestamps). Relative time is generally stored in a floating-point double.
But you should know that historically, before the timestamp datatype was added to LV, the double (and even the 32-bit INT) could be used to represent absolute times too, though with far less precision than the timestamp.
With all that in mind, please note that the Format Date/Time String primitive you were using really only formats absolute times. It will accept your floating-point double wire (which carries an elapsed time - you did a subtraction of two timestamps, after all), but it will interpret it absolutely - as so many seconds past the dawn of LabVIEW time - and since you asked for a format string of just H:M:S and fractional seconds, you'll always get a clock time - it'll roll over on time greater than 24 hours. (EDIT: is there no way to avoid the emoji reformatting? Arrgh! H colon M colon S)
Really, you should use the Format Into String primitive, and give it the "relative time" format specifier, which is %t, and which can be tweaked ad nauseum with the %<>t syntax. See the snippet I attached. No need to do the modulo math, it's all handled for you.
Hope this helps,
Dave
02-22-2018 04:23 AM
Thanks for that, I must admit I've never come across this way of solving the problem.
02-22-2018 04:29 AM
Thanks Ben64, that's a very neat solution. I'm somewhat confused by the format specifiers but I will use your example to educate myself and its always easier to learn from a working solution.
02-22-2018 05:06 AM
Thanks to all, I now have three working solutions but it does highlight that I need to work on understanding both string format syntax and time.
If anyone can recommend some background reading I have some studying to do.
Regards
As wise man one said " This must be Thursday, I never could get the hang of Thursdays" (Douglas Adams)