records dated after today delphi

HI:
I am struggling to write a delphi program that reads orders delivered after today.
The query works fine for all records but I am struggling to set the parameter 'today'
Here is the query:
""Query2.SQL.Clear;
Query2.SQL.Add('SELECT DISTINCT  D.DocNo,D.OrderNo, D.Ordered, D.Delivered,D.InvNo, D.Invoiced, D.AccNo, D.CRef,D.Items, D.Area,D.goods,D.Nett, D.VAT,D.SurchargeRate, D.SurchargeVal,D.State,D.held, 99 as roof ' );
 Query2.SQL.Add(' FROM "GOOrders.DB" D  WHERE  (D.Delivered >Date()) ORDER BY D.Delivered, D.AccNo');
 Query2.Open;""
It is the 'D.Delivered > Date()' that I cannot get.
Does anybody know how to set this, please?
Thanks!
Richard TeasdaleFinancial ControllerAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Pierre CorneliusConnect With a Mentor Commented:
You should use a parameter and set that before opening. In order for me to give example, I need to know of what type is Query2. Is it a TQuery?

Your sql should have something like:
WHERE  (D.Delivered >:ADate)

If you are using TQuery, you could set using
Query1.ParamByName('ADate').Value:= Date;
0
 
jimyXCommented:
Which Database you are using?
0
 
Richard TeasdaleFinancial ControllerAuthor Commented:
Paradox 7-11
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
what error do you get?
0
 
Richard TeasdaleFinancial ControllerAuthor Commented:
Thanks everybody!
It is a TQuery reading a Paradox database .THe error message is 'invalid use of keyword. Token:Date))
0
 
Pierre CorneliusCommented:
Don't use :Date, it is reserved word.

Use :ADate
or :Today

what follows the : is the name of the param and is what you should use in ParamByName.
0
 
Richard TeasdaleFinancial ControllerAuthor Commented:
Thank you very much! That has worked. Is it possible to set an end date, such as today +7 for the next week?
0
 
Richard TeasdaleFinancial ControllerAuthor Commented:
Thank you very much Pierre! And thanks to the other contributors, too.
0
 
Pierre CorneliusCommented:
You can set the date param to whatever you like. In delphi dates, the day is the integral part and time the fractional part, so to set to next week, you could use:
Query1.ParamByName('ADate').Value:= Date+7;
0
 
Richard TeasdaleFinancial ControllerAuthor Commented:
Thanks again Pierre - you get the points for a great answer; however the '+7' gives a type mismatch. I can resubmit as a new question if you prefer.
0
 
Pierre CorneliusCommented:
You're welcome.

try:
Query1.ParamByName('ADate').AsDate:= Date+7;

If still fails, perhaps you should set the param type:
Query1.ParamByName('ADate').DataType:= ftDateTime;
0
 
Richard TeasdaleFinancial ControllerAuthor Commented:
Thank you very much, Pierre. AsDate works.
0
 
Pierre CorneliusCommented:
Glad to help. Good luck.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.