split and replace functions

Results 1 to 2 of 2

Thread: split and replace functions

  1. #1
    hopie Guest

    Default split and replace functions

    HI...<BR>Anybody, pls help:<BR><BR>&#039I have a file that looks a bit like this:<BR><BR>147.204.222.210;mary How;Manufacturing;UK;Win;2/9/99 11:55:33 AM<BR><BR>&#039Now I want to retrieve the date:<BR><BR>strline = objText.ReadLine<BR>splitter = split(strline,";")<BR>Date_time = split(splitter(5)," ")<BR>tempDate = Date_time(0)<BR><BR><BR><BR>&#039tempdate gives me the date 2/9/99. I want it to be in format 9/2/99 so I tried to use the split then the replace function.<BR>But I get error...Whats&#039 wrong here? can&#039t I use the splt function again?<BR><BR><BR>temp = split(tempDate,"/")<BR>Replace tempDate,temp(0),temp(1)<BR>Replace tempDate,temp(1),temp(0)<BR><BR><BR>Error:<BR>Micr osoft VBScript runtime error &#039 800a0009&#039 <BR>Subscript out of range: &#039[number: 0]&#039 <BR><BR><BR>Please help...Is there any other way I can split the tempdate and change the format here? Note that I can&#039t use the datepart function, coz it gives error...the 2/9/99 seems to be an invalid date even though it looks like a date....<BR><BR>Thanks a lot.......<BR><BR>

  2. #2
    Imar Spaanjaars Guest

    Default RE: split and replace functions

    Why not just combine your date again with the array you build using split:<BR><BR>tempDate = temp(1) & "/" & temp(0) & "/" & temp(2)<BR><BR>If you need to format it to a correct date, use:<BR><BR>dateValue(tempDate)<BR><BR>Imar

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •