Strings & date sorting....

Results 1 to 3 of 3

Thread: Strings & date sorting....

  1. #1
    Wiiiiiil Guest

    Default Strings & date sorting....

    Hi,<BR><BR>I have a string : 4/4/96 4:30:00 PM<BR><BR>It&#039;s in a variable, lets call it string for the sake of simplicity. I want it to look like : 4/4/96<BR><BR>How do I do this? I know there&#039;s some way of chopping x number of characters from the right of a string but how do I do that?<BR><BR>Secondly, once I&#039;ve got a nice organised date style as above, how would I sort a large list of said dates in order. I.e. Make sure that 5/4/01 comes before 4/4/01?<BR><BR>Anything would be appreciated.<BR><BR>~ Will.

  2. #2
    Join Date
    Dec 1969

    Default RE: Strings & date sorting....

    strdate = Datevalue (left (string, instr (string, " ") - 1))

  3. #3
    Join Date
    Dec 1969

    Default RE: Strings & date sorting....

    Use this to format :<BR><BR>formatdatetime(string,2)<BR><BR>Then place them into an array and use the following function to sort :<BR><BR>&#039;*********************************** ************************************************** **<BR>function ArraySort(myArray)<BR><BR> Dim sorted <BR> Dim sorting <BR> Dim higher <BR> <BR> Do<BR> sorted = True<BR> For sorting = 0 To Ubound(myArray) -1<BR> If cdate(myArray(sorting)) &#062; cdate(myArray(sorting + 1)) Then<BR> higher = myArray(sorting)<BR> myArray(sorting) = myArray(sorting + 1)<BR> myArray(sorting + 1) = higher<BR> sorted = False<BR> End If<BR> Next <BR> Loop Until sorted<BR> <BR>end function<BR>&#039;******************************** ************************************************** ******<BR><BR>Cheers,<BR>Mike

Posting Permissions

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