TrDBGrid_MS and DateTime with time. Problems with filtering

20 views
Skip to first unread message

Volodymyr

unread,
Dec 4, 2024, 7:37:05 AMDec 4
to Rosi Delphi Components
I have a DB with DateTime filed with time, and I'm ok to have in one column the Date and Time.
But filter doesn't work with thiose fields. You can't choose "starts with" or "like" for DateTime.

I played a little with the demo, it has the same problem, see screenshot. When you apply a filter, it finds nothing. With the period it works only when the date inside of the period, not "from" or "to". In the example it shows 02.01.1994 12:30:00 only with period "01.01.1994"-"03.01.1994"

Are there any worarounds to work with DateTime fields?

With Best Regards
Volodymyr
Screenshot 2024-12-04 132503.png

Tomas Rosinsky

unread,
Dec 5, 2024, 12:12:34 PMDec 5
to Rosi Delphi Components
Hi Volodymyr,

TDateTime filed is not string but numeric value and therefore dataset does not support "start with" filtering like for texts.

You have to use period and define minimal and maximal date time for this period.
Then filter for range is generated, eg: ((HireDate>='01.05.1992') AND (HireDate<='02.05.1992'))
And you are right that in this case date 02.05.1992 10:00 is not shown because it is higher than 02.05.1992.  So you have to select 03.05.1992

I will check possible solution for DateTime field.

Regards
Tomas

Dne středa 4. prosince 2024 v 13:37:05 UTC+1 uživatel vkar...@gmail.com napsal:

Volodymyr

unread,
Dec 9, 2024, 7:03:55 AMDec 9
to Rosi Delphi Components
Thanks Tomas, 
As a quick solution I converted in my SQL select the field to the string. 
WBR
Volodymyr

Reply all
Reply to author
Forward
0 new messages