ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

date string comparison

I have a text file which has a date when a test was completed with the following format: 3/15/2004. If given a range of dates say 2/4/2004 - 5/6/2004, how do you compare the date string in the file to determine if it is in the date range given?

Thanks
0 Kudos
Message 1 of 6
(3,543 Views)
I would separate the year, month, and day and test each against the limits. In your example YearTest = YearUpper = YearLower (=2004). MonthUpper (=5) > MonthTest (=3) > MonthLower. Therefore, the DateTest is within the limits. For dates within the same month as one of the limits, the logic gets a little more complicated. If invalid dates can occur in your files (2/32/2004) you may need to test for that as well.

Lynn
0 Kudos
Message 2 of 6
(3,538 Views)
Another option would be to convert the date to LV time format which you can compare immediately. Basically, you convert the different parts to numbers and then use a combination of string and time functions to convert. You can see an example for part of this here.

___________________
Try to take over the world!
0 Kudos
Message 3 of 6
(3,533 Views)
Hey tst, that is a neat trick. How did you get the jpeg to display in the reply box?
- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 6
(3,527 Views)
Hi tbob, this was discussed in the feedback board. Basically, it's using html tags to display the picture, but it's a bit risky - you have to figure out the address of the attachment you're going to attach. I suggest if you're interested enough, you should go read there. I am afraid of people trying to do this and linking to the wrong pictures. Also, as you can see, it's still not perfect - that image icon is apparently redundant.

___________________
Try to take over the world!
0 Kudos
Message 5 of 6
(3,522 Views)
Thanks for the replys. Tst, that's what I ended up doing.
0 Kudos
Message 6 of 6
(3,504 Views)