Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Comparing database dates with a Date Filter

Posted on 2008-10-15
3
Medium Priority
?
820 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
[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 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

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

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…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
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 synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses

636 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