Solved

Comparing database dates with a Date Filter

Posted on 2008-10-15
3
816 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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. …
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

733 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