Arthur,
It doesn't matter what the length of the string is in this example. This
will leave everything to the right of the hyphen.
right(x,instr(x,"-")-1)
So if your original string is "12/05/05 - 12/05/05"
The result is " 12/05/05" (notice leading space)
depending on your exact needs, you can either replace the -1 with -2 if you
know a space will always follow the hypen. If you are unsure whether it will
be a space or a character you want to keep, then you could use
Trim(right(x,instr(x,"-")-1)) which will do away with leading and trailing
spaces.
Now, if your string may have more than one hypen, one method to do this
would be to use the Split function. Let's say your string is "12/05/05 -
12/05/05 - 12/05/06"
x= "12/05/05 - 12/05/05 - 12/05/06"
y = Split(x,"-") or you can get rid of the spaces on either side of the
hyphen by
y = Split(x," - ")
The result is an array. In this case, you would have 3 elements to the
array. (assuming we are using the example that eliminates the spaces as above)
y(0) = "12/05/05"
y(1)="12/05/05"
y(2)="12/05/06"
You can determine how many elements you have with the Ubound function
(assume Option Base 0)
Ubound(y) = 2
so, if all you want is the last part of the string to the right of all the
hypyens, the answer will be in the last element of the array.
"Arthur Zulu via AccessMonster.com" wrote:
> Thanks Klatuu..tried the replace"-" with "," and it works just fine....But
> i guess what i really wanted to do is delete all characters left of the
> Hyphen...
> for instance: "12/05/05 - 25/05/05"...
>
> delete all characters left of "-" and remain with 12/05/05...with out using
> functions like left(string,8)as the length of the string varies from record
> to record.
>
> is there anyone that can help?
>
> many thanks,
>
> Arthur
>
> --
> Message posted via http://www.accessmonster.com
>