Re: TZF -
| Newsgroups | gmane.comp.lang.delphi.topaz |
|---|---|
| Message-ID | <[email protected]> |
Jerry,
I have always had trouble with dates and filters, but here is a
routine that works for me with dates. It is rather spread out into
several steps. It is easier to debug that way. I have not got round to
consolidating the code. Since it works, I may just leave it as
inelegant as it is.
var
FilterExpression, DateTo find : string;
FindHiLoDate : TDateTime;
begin
....
{some code}
....
FindHiLoDate := Now - 365.0; // a year ago
DateToFind := DateToStr (FindHiLoDate);
FilterExpression := ('Date >= CTOD ("'+DateToFind+'")');
{ in the above, note the Double quotes around the single quotes around
the +DateToFind+ and the single quotes inside the outer parentheses}
TzStocks.SetFilterTo (FilterExpression);
TzStocks.Filtered := True;
TzStocks.GoTop;
...
{other code}
...
TzStocks.Filtered := False;
...
{Other code}
...
end;
Bill Marchant
Jerry Mallett wrote:
>Ok Guys ... my original question/query again and a new one.
>
>Extremely dissapointed at the lack of responses to my first question
>which for some of you guys I thought would have been a breeze.
>
>But here goes again.
>
>Original Question First
>------------------------
>Looking to filter a database on a date field. Is this possible. I'm
>having trouble doing so.
>SFilter being a string input date in the format 18/10/1953
>UK/Ireland date format.
>Competitors.SetFilterTo('DATES == "'+CTOD(SFilter)+'"');
>This line above does not work no matter what way I type it.
>
>Have tried the DTOC function as well as Marie suggested. No Good.
>---------------------------------------------
>
>
==^================================================================
This email was sent to: [email protected]
EASY UNSUBSCRIBE click here: http://topica.com/u/?clvXPN.a5kvff.Z2NsZHQt
Or send an email to: [email protected]
TOPICA - Start your own email discussion group. FREE!
http://www.topica.com/partner/tag02/create/index2.html
==^================================================================