LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to search date format in array

I don't have LabVIEW 8.2, but I'm reasonably certain these functions are present in that Version.  I was sorry to see the code you posted for the Date Search routine -- you clearly don't know about LabVIEW's Loop structures, nor have paid attention to the Help for the Scan from String function.

 

This Snippet takes an Array of Strings and passes it to a For loop (which is designed to test every element of an Array, without needing any explicit count of the Array size).  We use the Default input of Format Into String to define the output in case the Scan fails (which it will for a String that doesn't match the Date format you specify).  We also test the Offset Past Scan output which will be 0 if the Scan fails, and >0 if the Scan succeeds.  We use the Boolean >0 for two purposes -- first, if it is True, we have found the first Date, so we "Conditional Stop" the For Loop (and output the scanned TimeStamp), and we also bring this out of the For Loop as a TimeStamp Found indicator.

 

If the TimeStamp is found in the String, the TimeStamp Found Boolean will be True, the TimeStamp Out will be the decoded TimeStamp, and TimeStamp index will be the Index into the Input Array of the (first) found TimeStamp.  If no TimeStamp is found in the String Array, TimeStamp Found will be False, TimeStamp Out will be the default TimeStamp (numerically 0), and the TimeStamp Index (which won't be valid, since TimeStamp Found is False) will point to the last element of the Array.

 

I'm not sure what you intended to do with your sub-VI, but this does most of the work for you.

 

Find TimeStamp.png

Bob Schor

0 Kudos
Message 11 of 15
(1,383 Views)

this also not working.whenever i run 1'st time working correctly next time a while loop is stop 1'st iteration but that time search string numeric format not date format. 

0 Kudos
Message 12 of 15
(1,363 Views)

@GokulGKM wrote:

this also not working.whenever i run 1'st time working correctly next time a while loop is stop 1'st iteration but that time search string numeric format not date format. 


I think you need to show more context here.  You code works perfectly for me based on the data use supplied.


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 13 of 15
(1,336 Views)

Please post the failing code, as well as a data sample so we can test it and figure out why code works for us and fails for you.  It seems likely that you are doing something wrong, but without seeing the code (post VIs, please) and data, it is difficult to say where the problem could be.

 

Bob Schor

0 Kudos
Message 14 of 15
(1,321 Views)

The main problem is that timestamps could be a few seconds off, so the match will fail.

 

If the input array is sorted in time, I would probably just covert everything to DBL and use interpolate array to find the closest index.

Here's a draft. Modify as needed.

 

 

 

0 Kudos
Message 15 of 15
(1,304 Views)