Another date question

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Another date question

  • Creator
    Topic
  • #53884
    Vidya Sridhar
    Participant

      I have a list with 2 or more (upto 5) dates. I have to pick the record based on which one of them is closest to the current date, if they are less than current date. How do I do this is tcl?

      So far I have

      set x { a really long comma delimited list which has been spilt}

      set dateList2 [lrange $x 12 17]

      06/30/2012 05/31/2011 {} {} {} {}

      Here  I need to pick out 06/302012 as its the one closest to current date of 10/22/2013. I tried lsort, but I am not getting reliable results. I can always do expr to compare, but I don’t want to do that if i have all of the dates populated.  ðŸ˜¥

      Help?

      Vidya

    Viewing 2 reply threads
    • Author
      Replies
      • #79379
        Chris Williams
        Participant

          Hi Vidya,

          If you are the one building the list of dates, reformat the dates  to ccyymmdd before you add them to the list. Then using [lsort] will put them in chronological order.

          Cheers.

        • #79380
          Charlie Bursell
          Participant

            Good point but be sure to lsort -integer or you may not get the proper sort

          • #79381
            Vidya Sridhar
            Participant

              That worked like a charm! Thanks Chris and Charlie.

              However, I need to re-format the dates in more efficient way in the list than what I am doing now. Chris, to answer your question, I am not building the dates, they come in the mm/dd/yyyy format.

              Right now I am doing this to reformat

          Viewing 2 reply threads
          • The forum ‘Cloverleaf’ is closed to new topics and replies.