Solved

Comparing database dates with a Date Filter

Posted on 2008-10-15
3
814 Views
Last Modified: 2013-11-23
Hi,
I'm using the following block of code to filter mysql records.

        mysqltableClients.Filtered  := False;
        mysqltableClients.Filter    := 'contractor = '      + QuotedStr(contractor.text) +
                                                'AND assignedto = ' + QuotedStr(un.text) +
                                                   'AND cstatus = '    + QuotedStr('UNSIGNED') +
                                                   'AND status <> '    + QuotedStr('INVALID') +
                                                   'AND status <> '    + QuotedStr('NFC') +
                                                   'AND status <> '    + QuotedStr('COMPLETE') +
                                                   'AND status <> '    + QuotedStr('FADS') +
                                                   'AND lm < 4'           +
                                                   'AND apptdate = '  + QuotedStr('12/31/1899') +
                                                   'AND date > '         + QuotedStr('03/20/2008');
        mysqltableClients.Filtered  := True;

the problem is the last two comparisons.... apptdate and date
I am getting no records, when I know there are records that meet these conditions.

Isn't there a better way to compare date fields with static dates ?
What am I doing wrong?

Thanks in advance
0
Comment
Question by:delphimon
3 Comments
 
LVL 14

Expert Comment

by:SteveBay
ID: 22724978
Just a guess: Depending upon the database you are using appdate may in fact be equal to '12/31/1899 12:00'
0
 
LVL 21

Expert Comment

by:developmentguru
ID: 22725601
Honestly, with that many individual filter components, I would do it in a query instead.  If you have a large table your filter operation could be horridly slow.  If you need to know more about using a query in this instance I would need to know which database you are using.  It may also help to know how many records you have.
0
 

Accepted Solution

by:
delphimon earned 0 total points
ID: 22835808
Well, I ended up putting my date into an edit field like this...
apptdate.text := '12/31/1899';

and changed the code as follows:
Was: 'AND apptdate = '  + QuotedStr('12/31/1899')
Changed to: 'AND apptdate = '  + QuotedStr(apptdate.text)

And it works...
I really don't like this work around, but it works... ;-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

911 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now