0

I am using Delphi 7, and Titan BTrieve to open a Pervasive Table.

It is a TtbTable component.

I am trying to apply the filter on a TimeStamp field with my code as follows:

    Date:=InputDate;
    DateString:=FormatDateTime('DD/MM/YYYY HH:NN:SS', InputDate);
    Table1.Filter:='UPDATEDON > '+chr(39)+DAteString+chr(39);
    Table1.Filtered:=True;

The problem is that the filter results are incorrect. It returns records that are before the do not match the filter criteria.

mirtheil
  • 8,952
  • 1
  • 30
  • 29
Nico Steyn
  • 83
  • 3
  • 7

3 Answers3

1

the Table1.Filter, filters the data in TDataSet not in btrieve/pervasive.

the problem is the date in string format... you must use the formar YYYY-MM-DD and not DD-MM-YYYY because the string compare.

in a string compare 17-06-2012 is grater than 16-07-2012, (17>16)

Pedro Lopes
  • 175
  • 10
0

From the look of it, you are comparing strings, not dates.

Marco van de Voort
  • 25,628
  • 5
  • 56
  • 89
  • I am comparing dates, but to build a filter the date parameters need to be converted and passed as string. This is the way of it with TTable filter. This component is inherited from ttable. – Nico Steyn Jul 15 '12 at 17:27
0

What version of PSQL are you using? Is the UPDATEDON field defined as a Timestamp in the Btrieve database? If it's a timestamp, values are stored in 8-byte unsigned values representing septaseconds (10^-7 second) since January 1, 0001 in a Gregorian calendar, Coordinated Universal Time (UTC). It is not stored as a string.

Btrieve / PSQL stores dates in the 'YYYY-MM-DD' format.

WHat does a value from the UPDATEDON field look like? To use it as a filter, you need to make sure the filter value looks the same.

mirtheil
  • 8,952
  • 1
  • 30
  • 29
  • Thank you I checked all of this and nothing seems to be working. Pervasive has formatting checks and my filter parameters pass these checks. They must have a bug in their component. My formatting was spot on I have tested it now in DBISAM and DBASE and PARADOX and it worked perfectly. Just with pervasive now I am having a problem and it must be the component that is buggy. Thank you. – Nico Steyn Jul 15 '12 at 17:25
  • You may be able to find what the error situation is (and work around it) by supplying ever more complex datetime strings. Start with '1-1-1' and '1/1/1', then try '15/5/1' and '5/15/01' etc. – Jan Doggen Jul 15 '12 at 17:33
  • @Nico, If you use the PCC (or ODBC Test)and read the UPDATEDON field, what does a value look like? Does the standard TTable component work? What about PDAC (Pervasive's VCL control)? – mirtheil Jul 15 '12 at 18:57