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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Editng a string

Status
Not open for further replies.

azrael811

MIS
Sep 2, 2003
13
0
0
AU
I wish to edit the contents of a string so I can use it for comparison. The string is the creation date of a file and its format is "dd/mm/yyyy hh:mm:ss xm" how can I remove the time from the string as the date is the only thing I am interested in ????
 
That's a good question.
I'd really like to know how to do a substring in VBscript (if you can)...
I had something similar and I ended up using a loop to search through the string for all instances of ~ as I was using this to break the file up. And then i used to Split function.

I'd suggest you could do the Split function and then just search the array(0) for your date.... Split based on a space (" ").
eg DateArray = Split(strDateTime, " ", -1, 1)
This would break it up by dates and the first array element is your date...
 
Hello azrael811,
Code:
sDT = "dd/mm/yyyy hh:mm:ss xm"
sD = Left(sDT,InStr(1,sDT," ",1)-1)
wscript.echo sD
But make sure sDT really is a string as such.

regards - tsuji
 
Ahhh so easy!! Why couldn't they just use a function called SubStr or Substring!!

Thanks for your help tsuji.... :)
 
To get the 10 ten chars of a string, just do this:
Code:
NewStr=Left(OldStr,10)

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top