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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Sorting dates in a Listcontrol

Sorting dates in a Listcontrol

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelpalgorithmslearning
2 Posts 2 Posters 0 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.
  • M Offline
    M Offline
    Megastoffel
    wrote on last edited by
    #1

    Hi I have a problem with sorting dates in a Listcontrol. When I add some dates they are sorted by day but I want to sort them by day AND month AND year of course. How do I do that? (sorry for the probably stupid question) now I get e.g. 1. 13 May 2003 2. 14 February 2005 3. 15 August 2001 4. 16 May 2003 And I want 1. 15 August 2001 2. 13 May 2003 3. 16 May 2003 4. 14 February 2005 please help me!:confused:

    M 1 Reply Last reply
    0
    • M Megastoffel

      Hi I have a problem with sorting dates in a Listcontrol. When I add some dates they are sorted by day but I want to sort them by day AND month AND year of course. How do I do that? (sorry for the probably stupid question) now I get e.g. 1. 13 May 2003 2. 14 February 2005 3. 15 August 2001 4. 16 May 2003 And I want 1. 15 August 2001 2. 13 May 2003 3. 16 May 2003 4. 14 February 2005 please help me!:confused:

      M Offline
      M Offline
      Martyn Pearson
      wrote on last edited by
      #2

      The sorting that is being performed is a string sort - i.e. they are in alphanumeric order. What you need to do in the sorting function is convert the textual representation of the date to say, a CTime, then determine the order from that. The other option is to display the date in the format YYYY/MM/DD; when you do this the string sort operation correctly sorts the dates!

      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