LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Searching Dates using Match Pattern

I am trying to search for dates between a inputed set of dates.  I have included a picture of the controls and part of the code to better demonstrate this.  Basically I have a tab delimited txt file with many columns of data.  In one of those colums there are dates.  Currently the format is M/D/YYYY.  I can format the date whichever way I like to make the searching easier (so don't let the current format limit solutions).  On the panel, the user is able to select a start and end date to search through.  From there I assembly a string in the format of [M-M]/[D-D]/[YYYY-YYYY] and do a Match Pattern against each row in column of dates.  My match pattern fails when searching for [1-12]/[1-31]/[2007-2010] in 2/7/2007.  I further experimented with the Match Pattern VI and found that it doesnt work for double digit searches (For Example [1-31] really only searches for [1-3]) which is why it is failing.  If anyone has a solution for this or advice, please let me know.
 
Thanks in advance.
Aaron Colunga
0 Kudos
Message 1 of 10
(4,404 Views)
Graphic did not post, here it is.
0 Kudos
Message 2 of 10
(4,399 Views)
I have made some progress but ran into another problem.  I split the two digit numbers into arrays and ran searches for them individually.  For example instead of searching [1-31] I now have match pattern search for [0-3][0-1].  This works some of the time but has its obvious limitations.  I cut out and simplified the VI to show my current solution and what I am trying to do.  I am attaching it with this post.
0 Kudos
Message 3 of 10
(4,381 Views)

The system I'm on doesn't have LV, so can't show you a VI, however the following should help...

Use 'date/time rec to seconds' to get your start and end dates in seconds (U32) since the epoch. You only need set D/M/Y fields - leave the rest at zero.

Now do the same with your date from the txt file. Use scan from string as needed to get D, M, and Y as integers.

Now it's just a straight integer comparison.

The year has to be in the range of date/time rec (1904 - 2040)

Rod.

Message 4 of 10
(4,368 Views)
Here is a vi that does what Rod says.  However, I couldn't find "date/time rec to seconds" in LV 8.2.  I did find "Date/Time to Seconds" only it does not produce a U32 for its output, it produces a timestamp.  But I was able to convert all dates into timestamps and used In Range to determine if the example date fell within the specified range. 
 
Why doesn't Date/Time to Seconds produce a numerical output representing the number of seconds since whatever that date is?
- tbob

Inventor of the WORM Global
Message 5 of 10
(4,351 Views)
I think I understand what your saying Rod.  That is, instead of trying to compare strings I should convet my string date info into a numeric representation of the number of seconds and compare that? By the way, I am uploading a graphic showing my previous solution for you.
 
tbob:  I would really like to see your solution except I am running LV 8.0.  Could you take a picture of the code or save it as a previous version type for me to see please?
0 Kudos
Message 6 of 10
(4,341 Views)
I forgot to say thanks for the help, so... thanks for the help 🙂
 
Aaron Colunga
0 Kudos
Message 7 of 10
(4,340 Views)
Here it is in 8.0.  I still want to know why Date/Time to Seconds produces a timestamp output instead of a numeric.  Anybody?
 
 
- tbob

Inventor of the WORM Global
Message 8 of 10
(4,332 Views)

The perils of being used to an older version of LabVIEW!

According to the update notes for Rev 7.0 http://www.ni.com/pdf/manuals/321780e.pdf, (page 36) the change from U32 to time stamp was made to allow time to be stored at geater precision and range of values. Time stamp is a 128 bit signed value, with conversions available to maintain compatibilty. The bottom 64 bits represent fractions os a second. Year can now be on the range 1600 to 3000. Dates before 1904 have a negative time stamp.

Rod.

.

 

Message 9 of 10
(4,318 Views)
The VI works great, does exactly what I need it to and is a lot cleaner solution.  Thanks you very much for your help.
0 Kudos
Message 10 of 10
(4,302 Views)