0

I am populating a list of items into a TComboBox item list. But the items are not saved as Dates in the Database I am getting them from. Delphi sorts the items as a string. How could I sort these items as dates instead please?

The list will never have the same amount of Dates because as I filter the list will get shorter or longer... so assigning each item is out of the question. Can someone please assist.

Regards

  • 4
    Parse the strings as `TDateTime` values and sort on them as needed. If you need more help, you will have to show what the strings actually look like and how you are populating the ComboBox with them – Remy Lebeau Feb 22 '18 at 05:32
  • There's a lot of information missing. TComboBox.Items are strings, that's a fact. But who is sorting the dates? What database are you using? Who is loading the dates in the items? Assigning each item may be out of the question, but somebody is doing it right now. Please show some code, if you want us to help you solve this problem. – Frazz Feb 22 '18 at 10:41
  • I am using an Access database with workplaces in one column and tasks in another. Each task has a date.. so using SQL QRY I recall the tasks for each panel... the dates look as follows (03/09/2018) dd/mm/yyyy. I the add the items by running through the database where panels are the same... hope this gives you an idea. So there can be different amounts of dates shown in the TComboBox... but they should be sorted as dates... Thanks in advance. – Marius Schoeman Feb 23 '18 at 07:23
  • This is the line of code which ads the lines... QAUDITDATESCB.Items.Add(QLISTQRY.fieldbyname('LAST_VISIT').AsString); I tried changing "AsString" to "AsDateTime" but then I get an error on runtime. Maybe it has to be declared or something. Regards – Marius Schoeman Feb 23 '18 at 07:28

0 Answers0