TDBF filter using dates? lazarus / 16-Databases ---------------------------------------------------------------------- bill0287 · 2014-02-02 00:40 I am struggling with getting the right syntax to filter a tdbf on a date looked up by the user.  I have a DBLookupComboBox that pulls a list of dates from the field called DATE. They are in the format mm/dd/yyyy. I want to filter for that date something like this: Code: [Select]Filter:='DTOS(DATE) = "yyyymmdd"' but I can't figure out how to change the string value in the combobox to YYYYMMDD (needed by the filter statement) and then substitute it into the filter statement so that it works. I tried many variations and nothing so far has worked. If anyone has any helpful suggestions I would be grateful. ---------------------------------------------------------------------- mangakissa · 2014-02-02 10:28 Translated from Dutch: Why bring the mountain to Mohammed if Mohammed can go to the mountain! If the field of your date has a date as filedtype, why not using a simple thing like this: Code: [Select]Tdbf.filter := 'date = ' + tdbf.fieldbyname('date').AsDateTime; ---------------------------------------------------------------------- LacaK · 2014-02-02 10:52 Quote from: bill0287 on February 02, 2014, 01:40:39 ambut I can't figure out how to change the string value in the combobox to YYYYMMDD (needed by the filter statement) and then substitute it into the filter statement so that it works. if you want translate date string to other formated date string ... you can use something like:   formatdatetime('yyyymmdd', strtodate(cbDate.Text)) ---------------------------------------------------------------------- bill0287 · 2014-02-02 17:08 Thanks for the help...this seems to work for my situation: Code: [Select]          mydate := formatdatetime('yyyymmdd', strtodate(DBLookupComboBox.Text));           Filter := 'DTOS(DATE) = ' + AnsiQuotedSTR(mydate,'"'); Where DATE is a field of TDateField and DBLookupComboBox is the list of dates in that field.