Solved

DateTime and TTable  filtering

Posted on 2003-10-30
3
260 Views
Last Modified: 2010-04-03
   s:='HOSPITAL='''+IntToStr(ComboBox1.ItemIndex)+'''';
    s:= s + ' and DATA >='''+ DateToStr(StartD.Date) + ''' and DATA <='''+ DateToStr( EndD.Date)+''' ';
    Table1.Filter := s;

Using upside code I get a filtering just after day, but I wish to filter by day, month and year. Where I wrong ?
0
Comment
Question by:ginsonic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 150 total points
ID: 9655914
if StartD.Date and EndD.Date are results from TDateTimePickers,
then there is a timefragment included

try following change


    s:= s + ' and DATA >='''+ DateToStr(Trunc(StartD.Date)) + ''' and DATA <='''+ DateToStr(trunc(( EndD.Date))+''' ';

on the other hand, datecompares are also pending on regional settings

meikl ;-)
   
0
 
LVL 17

Assisted Solution

by:geobul
geobul earned 100 total points
ID: 9656332
Hi,

What is the type of your DATA field - date or string? In both cases I would recommend FormatDateTime('your database date format', StartD.Date) instead of DateToStr.

Regards, Geo
0
 
LVL 4

Expert Comment

by:Greg Rowland
ID: 9657584
Geo is correct FomatDate is a much stronger solution.

Otherwise with some date types you can end up with long dates like “2003-07-16 02:21:45.192” which do not evaluate as expected.


Excerpt
        QueryString := 'where LOGINDATE >= ' + #39 + FormatDateTime('mm/dd/yyyy', (Date - 185)) + #39 +
          ' and LOGINDATE <= ' + #39 + FormatDateTime('mm/dd/yyyy', (Date + 185)) + #39


0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question