Convert to an array...assistance required

Results 1 to 5 of 5

Thread: Convert to an array...assistance required

  1. #1

    Default Convert to an array...assistance required

    Im wanting to use the following selection of code to convert my date values into an array...<BR><BR> StartDate = CDate( request.form("startdate") ) <BR> Finishdate = CDate( request.form("finishdate") ) <BR><BR> daily = ( CINT(request.form("option")) = 1 ) <BR> If daily Then <BR> inter_count = 1 <BR> Else <BR> inter_count = CINT( request.form("daily") ) <BR> End If <BR><BR> Do Until StartDate &#062; Finishdate <BR> <BR> If ( Not daily ) OR ( Weekday(StartDate) &#060;&#062; 1 AND Weekday(StartDate) &#060;&#062; 7 ) then<BR><BR>************************************** *<BR>THIS IS WHERE IM NOT SURE<BR><BR>MyDate = MyDate & StartDate & ","<BR>***************************************<BR> <BR> End If <BR> <BR> StartDate = DateAdd("d", inter_count, CDate(StartDate)) <BR> <BR> Loop <BR> <BR>&#039;CONVERT IT TO A SESSION VARIABLE HERE FOR USE LATER<BR>session("MyDate") = MyDate <BR> <BR><BR>Thank you,<BR>John<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Convert to an array...assistance required

    MyDate = MyDate & StartDate & "," <BR><BR>That&#039;s appending onto a string, that&#039;s not creating an array. If you want an array, you could finish your loop and then do:<BR><BR>Session("MyDate") = Split(MyDate, ",")<BR><BR>Craig.

  3. #3

    Default Yes, I knew it wasnt right, however

    I really had no idea. With what you have suggested<BR><BR>Session("MyDate") = Split(MyDate, ",")<BR><BR>Should I still go ahead and use the first section of the original peice of code? I mean, if its wrong, should I ditch it?<BR><BR>When passing values beforehand and writing them to screen, I get something like this....<BR><BR>12/11/2003,13/11/2003,14/11/2003,15/11/2003,<BR><BR>You will notice the comma at the actual end of the string...or line? I guess its not really a string is it? Or is it?<BR><BR>Also, I tried beforehand using the split function and it errored out? Not sure....<BR><BR>Thanks Craig,<BR>John

  4. #4
    Join Date
    Dec 1969

    Default RE: Yes, I knew it wasnt right, however

    Of course it&#039;s a string.<BR><BR>Yeah, that trailing comma will mean that the array you get will have one too many elements (a "blank" one at the end). That&#039;s solve-able though.<BR><BR>If Len(MyDate) &#062; 1 Then<BR> If Right(MyDate, 1) = "," Then MyDate = Left(MyDate, Len(MyDate)-1)<BR>End If<BR><BR>Ok, it looks nasty, but it&#039;s quite straight-forward. It says "If the length of MyDate is greater than one, then...". This is just to stop any errors. It then says "If the last character in MyDate is a comma, then reduce the length of MyDate by one character (i.e. "remove the last character - the comma").<BR><BR>And then it&#039;s fine - splitting it should get you the array you&#039;re after...<BR><BR>Craig.

  5. #5

    Default Brilliant...

    Youre an absolute champion Craig, thank you.<BR><BR>Ill give this a try now.<BR><BR>Regards,<BR>John

Posting Permissions

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