Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to compare

Status
Not open for further replies.

smiler44

Technical User
Sep 18, 2009
83
0
0
GB
minds gone blank. I have scraped some text from my screen 22/12/13 and want to compare it to todays date.
todays date will change day by day and so will the text I scrape from my screen. how to I compare the two to see
if the date (text) I have scraped from by screen is less than todays date?

also dim variable name as date does not work, I'm sure it should. how do you declare a variable as a date?

thanks
smiler44
 
Hi,

EVERYTHING, that is every piece of data that you scrape from a terminal emulator, is TEXT.

A date is a NUMBER.

so you must parse the string into year, month and day, and use a date() function to convert to a number (real date). Of course you must add the century to the year.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
skip, thank you but I don't understand fully. I get the text and number part. I have come up with a way, may be long winded but this is how I've done it:

scraped data/date = 25/12/13
todays date = 05/01/14
I compare the 13 to the 14. 14 is greater, no more checks use the 05/01/14 date
if 13 and 14 were equal then compare 12 and 01. 12 is greater, no more checks use date that has 12 in it
if 13 and 14 were equal and the 12 and 01 were equal then compare 25 and 05. 25 is greater use that date
if todays year is greater use that date
if years are equal then compare months, use the date with the greater month
if years and months are equal use the date with the greater day.

This has overcome one problem, leaves me with another that I may have the answer to. If using todays date and today is a Saturday or Sunday then use the date of the next working day. How do I get the next working day's date?

skip would like to see a full version of your way.

smiler44



 
I'm using my iPad, so don't have the Extra VB Help reference.

Furthermore, I always use Excel VBA, light years better than Extra, to scrape, and all my data ends up in Excel anyhow.

That being said, check for DateSerial() function in Extra Help. This will return a Date Value (a NUMBER), that you can compare with your current date.

You really ought not compare year, month & day individually as you have described. CONVERT strings to Date Values (NUMBERS) for ANY date comparison or calculation!

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Check this out...

thread1-1503640


Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
skip I agree vba is better but does that not then involve using two programmes, Excel and attachamate?
using two programs would not be very smooth. I have looked at the link you sent me and copied some of the code to try.

appreciate the help.

smiler44
 
In my experience, I'm providing data for my users. That ALWAYS involves Excel as the end product. So I never saw a benefit to using Extra VB. In fact it is an impediment, as I much prefer to drive a Cadillac than a Yugo!

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
skip I have tried your code and can see that it gets the last working day of the month. I think it uses Monday to friday as the working week which is fine. i can not work out how to modifiy the function to give me the next working day's date after today not matter what day today is.

could you give me some more guidence?
thanks
smiler44
 
skip i also read the extra help on dateserial. i did not understand it

most of my stuff "does not require" excel as i dont have any reason to interact with it. to ask users to open excel to run a macro in attachmate when they hve no data to be used from or entered into excel, i dont go with this.
smiler44
 
Well, instead of the LAST day of the month, use your date. The procedure loops, incriminating the day until a working day of the week is encountered.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top