LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

date comparison

Solved!
Go to solution

Hello All

The attached vi searches a directory which contains txt files with the name format File_2011.02.17.txt...viz the file is named on the date it is created.

 

The purpose of the directory search is to determine if a file already exists....if it doesn't, then something else happens (this part of the code is not included nor is it relevant)

 

The date part of the file is created using the Get Date/Time in seconds format.

 

After searching the directory and finding the latest txt file I am then attempting to compare it with the current date.

 

This is where I'm having a little trouble, and would appreciate any assistance.

 

I'm sure it's a very minor thing to do, but I've always had trouble with timestamps, dates etc.

 

Thank you and best regards

Ray

Download All
0 Kudos
Message 1 of 20
(5,279 Views)
Solution
Accepted by topic author rayclout

You can use a simple regular expression to extract the date components from the file name. Then you can convert them to numbers and compare then at will. I would recommend calculating a Julian date from the components so you only need to do one comparison.

Date Parser.png



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 20
(5,264 Views)

Hello Mark

Firstly thank you for your interest

 

I assume the function you have used here is a Match Regular Expression. I'm using LV2009 on XP, and this function I have looks different to yours. For a start it doesn't have the three seperate string outputs on the right hand side, but rather....before match, whole match and after match.

 

Am I missing something here?

 

Ray

0 Kudos
Message 3 of 20
(5,254 Views)

Answered my own question....drag the bottom of the vi down to expand....simple

0 Kudos
Message 4 of 20
(5,247 Views)

The Regular Expression function can be expanded by grabbing the bottom of the function and pulling down (like many other LV functions)

 

You could also drag Mark's example from your browser and drop it on your block diagram, it's called a VI Snippet.

0 Kudos
Message 5 of 20
(5,246 Views)

Phillip

That process doesn't work for me.

 

See attachment for what drops onto my BD

 

R

0 Kudos
Message 6 of 20
(5,241 Views)

Mark

I took your advice on all counts and it works. It may be convoluted and a knight could do it in half as many functions (have a look) but it does work.

 

Thanks again

 

Ray

 

 

Download All
0 Kudos
Message 7 of 20
(5,232 Views)

Then please give credit to Mark for giving you the solution by marking his message as the solution and not your own.  You can unmark your message by going to the options menu to the upper right of your message.

0 Kudos
Message 8 of 20
(5,220 Views)

 


@rayclout wrote:

Phillip

That process doesn't work for me.

 

See attachment for what drops onto my BD

 

R


 

I'm  guessing you are using Firefox or Chrome. I think there is a known issue with these browsers. Internet Explorer should work.

 

By the way, I just upgraded my home laptop to IE 9 and now I can't drop a snippet using IE either Smiley Sad

0 Kudos
Message 9 of 20
(5,200 Views)

Ravens Fan

Where did I mark my message as the solution and not Marks?

 

I must be going blind

0 Kudos
Message 10 of 20
(5,185 Views)