Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. Asp Split and Join

Asp Split and Join

Scheduled Pinned Locked Moved Web Development
tools
6 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi i have a script im trying to get to work i need to split a date an re-join it back in a different order heres what i have so far, i can get it to split buti need to join it back into one again. ages = request.querystring("age1") agesplit = Split(ages, ",") Dim agesplit(3) one = agesplit(0) two = agesplit(1) three = agesplit(2) Dim OneDimArray(3) OneDimArray(2) = one OneDimArray(0) = two OneDimArray(1) = three Dim strSentence strSentence = join(OneDimArray) cheers

    U G A 3 Replies Last reply
    0
    • L Lost User

      Hi i have a script im trying to get to work i need to split a date an re-join it back in a different order heres what i have so far, i can get it to split buti need to join it back into one again. ages = request.querystring("age1") agesplit = Split(ages, ",") Dim agesplit(3) one = agesplit(0) two = agesplit(1) three = agesplit(2) Dim OneDimArray(3) OneDimArray(2) = one OneDimArray(0) = two OneDimArray(1) = three Dim strSentence strSentence = join(OneDimArray) cheers

      U Offline
      U Offline
      User 556471
      wrote on last edited by
      #2

      ages = request.querystring("age1") agesplit = Split(ages, ",") Dim agesplit(3) one = agesplit(0) two = agesplit(1) three = agesplit(2) Dim strSentence strSentence = two & "/" & three & "/" & one e.g., 31/12/2005 (dd/mm/yyyy) and u wanna to write it as 12/2005/31 (mm/yyyy/yy)

      1 Reply Last reply
      0
      • L Lost User

        Hi i have a script im trying to get to work i need to split a date an re-join it back in a different order heres what i have so far, i can get it to split buti need to join it back into one again. ages = request.querystring("age1") agesplit = Split(ages, ",") Dim agesplit(3) one = agesplit(0) two = agesplit(1) three = agesplit(2) Dim OneDimArray(3) OneDimArray(2) = one OneDimArray(0) = two OneDimArray(1) = three Dim strSentence strSentence = join(OneDimArray) cheers

        G Offline
        G Offline
        Guffa
        wrote on last edited by
        #3

        Don't dimension agesplit as an array. It's not an array, it's a variant that contains an array. When you dimension an array in VBScript, you don't give the number of items, but the highest index to use. If you want an array with three items, the highest index will be two. Dim ages, agesplit, strSentence Dim OneDimArray(2) ages = Request.QueryString("age1") agesplit = Split(ages, ",") one = agesplit(0) two = agesplit(1) three = agesplit(2) OneDimArray(2) = one OneDimArray(0) = two OneDimArray(1) = three strSentence = join(OneDimArray, ",") --- b { font-weight: normal; }

        L 1 Reply Last reply
        0
        • G Guffa

          Don't dimension agesplit as an array. It's not an array, it's a variant that contains an array. When you dimension an array in VBScript, you don't give the number of items, but the highest index to use. If you want an array with three items, the highest index will be two. Dim ages, agesplit, strSentence Dim OneDimArray(2) ages = Request.QueryString("age1") agesplit = Split(ages, ",") one = agesplit(0) two = agesplit(1) three = agesplit(2) OneDimArray(2) = one OneDimArray(0) = two OneDimArray(1) = three strSentence = join(OneDimArray, ",") --- b { font-weight: normal; }

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Thanks for the help so far well heres what im trying to do with not much luck, i hate betweens grrr 'Dimension variables Dim adoCon2 Dim rsUser2 Dim strSQL2 Dim lngRecordNo2 Dim access lngRecordNo2 = Request.QueryString("ID") times = request.querystring("age2") sDate2 = times myArray2 = Split(sDate2, "/") sNewDate2 = myArray2(1) & "/" & myArray2(0) & "/" & myArray2(2) Dim ages, agesplit, strSentence Dim OneDimArray(2) ages = Request.QueryString("age1") agesplit = Split(ages, "/") one = agesplit(0) two = agesplit(1) three = agesplit(2) OneDimArray(2) = one OneDimArray(0) = two OneDimArray(1) = three strSentence = join(OneDimArray, "/") 'Create an ADO connection odject Set adoCon2 = Server.CreateObject("ADODB.Connection") 'Set an active connection to the Connection object using a DSN-less connection adoCon2.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("database.mdb") 'Create an ADO recordset object Set rsUser2 = Server.CreateObject("ADODB.Recordset") 'Initialise the strSQL variable with an SQL statement to query the database strSQL2 = "SELECT * FROM student WHERE dob BETWEEN #"&strSentence&"# AND #"&sNewDate2&"# Order By student_id ASC" 'Open the recordset with the SQL query rsUser2.Open strSQL2, adoCon2...

          G 1 Reply Last reply
          0
          • L Lost User

            Hi i have a script im trying to get to work i need to split a date an re-join it back in a different order heres what i have so far, i can get it to split buti need to join it back into one again. ages = request.querystring("age1") agesplit = Split(ages, ",") Dim agesplit(3) one = agesplit(0) two = agesplit(1) three = agesplit(2) Dim OneDimArray(3) OneDimArray(2) = one OneDimArray(0) = two OneDimArray(1) = three Dim strSentence strSentence = join(OneDimArray) cheers

            A Offline
            A Offline
            Anonymous
            wrote on last edited by
            #5

            Ive cracked it thanks for the help heres my final code snipet Dim adoCon2 Dim rsUser2 Dim strSQL2 Dim lngRecordNo2 Dim access lngRecordNo2 = Request.QueryString("ID") times = request.querystring("age2") times2 = request.querystring("age1") sDate2 = times myArray2 = Split(sDate2, "/") sNewDate2 = myArray2(0) & "/" & myArray2(1) & "/" & myArray2(2) sDate = times2 myArray = Split(sDate, "/") sNewDate = myArray(0) & "/" & myArray(1) & "/" & myArray(2) Set adoCon2 = Server.CreateObject("ADODB.Connection") adoCon2.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("database.mdb") Set rsUser2 = Server.CreateObject("ADODB.Recordset") strSQL2 = "SELECT * FROM student WHERE dob BETWEEN #"&sNewDate&"# AND #"&sNewDate2&"# Order By student_id ASC" rsUser2.Open strSQL2, adoCon2

            1 Reply Last reply
            0
            • L Lost User

              Thanks for the help so far well heres what im trying to do with not much luck, i hate betweens grrr 'Dimension variables Dim adoCon2 Dim rsUser2 Dim strSQL2 Dim lngRecordNo2 Dim access lngRecordNo2 = Request.QueryString("ID") times = request.querystring("age2") sDate2 = times myArray2 = Split(sDate2, "/") sNewDate2 = myArray2(1) & "/" & myArray2(0) & "/" & myArray2(2) Dim ages, agesplit, strSentence Dim OneDimArray(2) ages = Request.QueryString("age1") agesplit = Split(ages, "/") one = agesplit(0) two = agesplit(1) three = agesplit(2) OneDimArray(2) = one OneDimArray(0) = two OneDimArray(1) = three strSentence = join(OneDimArray, "/") 'Create an ADO connection odject Set adoCon2 = Server.CreateObject("ADODB.Connection") 'Set an active connection to the Connection object using a DSN-less connection adoCon2.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("database.mdb") 'Create an ADO recordset object Set rsUser2 = Server.CreateObject("ADODB.Recordset") 'Initialise the strSQL variable with an SQL statement to query the database strSQL2 = "SELECT * FROM student WHERE dob BETWEEN #"&strSentence&"# AND #"&sNewDate2&"# Order By student_id ASC" 'Open the recordset with the SQL query rsUser2.Open strSQL2, adoCon2...

              G Offline
              G Offline
              Guffa
              wrote on last edited by
              #6

              When working with the database, I would suggest that you format the date according to ISO 8601, e.g. "yyyy-mm-dd". This format is totally unambigous (contrary to almost all other date formats), and the database should have no problems to dechiper it, regardles of what the date format might currently be on the server. --- b { font-weight: normal; }

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups