LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

string to time conversion

I am trying to convert 2 strings in this format below to time so i can subtract them from each other to get the difference. I found example online that work in a new version of Labview but doesnt work in labview 7. Can anyone help?

 

15:23:54.315 - 15:22:54.315 = 1 min.  This 1 minute will be used to be an input to a wait (ms)  time delay.

This is in the string format. If it was in a time format it would be easy to subtract the 2. Also i will be reading in the numbers from a file so this is just an example of how the strings will be displayed the time are different.

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

Use Scan From String.


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
0 Kudos
Message 2 of 5
(2,947 Views)

I tried this solution but with labview 7.1 when i enter %<%H:M:%S%u>T the output from the Scan from string is a blank White and can't be inputed in to anything it shows error. void broken wire you may have entered an empty control

0 Kudos
Message 3 of 5
(2,918 Views)

I'm pretty sure LV 7.1 didn't support scanning timestamps using the Scan From String primitive.

 

Instead, you can use Scan From String to scan the various elements separately (using a format string of the style %d:%d:%d, etc.) and then either build them into a date time cluster and convert that to a timestamp using the relevant function, or multiply each part by the correct amound and add them all together. Since in both cases you're subtracting, you're going to end up with relative time, so it doesn't really matter which way you take.


___________________
Try to take over the world!
0 Kudos
Message 4 of 5
(2,911 Views)
Given you are working in V7.1 I think I'd go with the easiest solution possible. Turn the string into an array of DBLs using the colon as the delimiter.

Then multiply the resulting 3 element array by an array containing the values: 3600, 60 and 1.

Now add all the elements together.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 5
(2,875 Views)