Jump to content
Macro Express Forums

Find A Variable Date


Recommended Posts

I need to find a variable date within a Variable String... example... I need to look and see if there is a date of May 2006. It could be any day... and the date format is 05/15/2006. It could be any day within the month... I just need to find if May 2006 exists and do some functions if it does. Is this possible without using up a ton of variables?

Link to comment
Share on other sites

Here is one idea:

This sample has been edited to correct a mistake:

// Copy variable containing entire string to a work variable
Variable Modify String: Copy %T1% to %T90%
// Set T13 to ASCII char CR
Variable Set %T13% to ASCII Char of 13

// Set T10 to ASCII char LF
Variable Set %T10% to ASCII Char of 10

// Replace all CRs and LFs with a space
Replace "%T13%" with " " in %T90%
Replace "%T14%" with " " in %T90%

// Replace all periods followed by a space ". " with " . "
Replace ". " with " . " in %T90%

If Variable %T1% contains " 05/"
If Variable %T1% contains "/2006 "
 // Here: we know that T1 contains 05/xx/2006
End If

One refinement might be to test the characters between " 05/" and "/2006 " to make sure that there are 2 of them and that they are numbers.

Link to comment
Share on other sites

Thanks Kevin. Problem is that the spreadsheet I am working off of has mulitple dates... It can have up to 5 "05/" (for 2000 through 2005) and up to 12 "/2005". I think I have found a work around... I am just finding the first /2005, setting the interger, subtracting 6, and copying the 2 digit month to see if it equals "05" text. Thanks!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...