Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

records dated after today delphi

Posted on 2014-03-24
13
Medium Priority
?
363 Views
Last Modified: 2014-03-24
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!
0
Comment
Question by:ClaytonGlass
[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
13 Comments
 
LVL 24

Expert Comment

by:jimyX
ID: 39950015
Which Database you are using?
0
 

Author Comment

by:ClaytonGlass
ID: 39950025
Paradox 7-11
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39950026
what error do you get?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 14

Accepted Solution

by:
Pierre Cornelius earned 1000 total points
ID: 39950046
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
 

Author Comment

by:ClaytonGlass
ID: 39950057
Thanks everybody!
It is a TQuery reading a Paradox database .THe error message is 'invalid use of keyword. Token:Date))
0
 
LVL 14

Expert Comment

by:Pierre Cornelius
ID: 39950065
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
 

Author Comment

by:ClaytonGlass
ID: 39950090
Thank you very much! That has worked. Is it possible to set an end date, such as today +7 for the next week?
0
 

Author Closing Comment

by:ClaytonGlass
ID: 39950093
Thank you very much Pierre! And thanks to the other contributors, too.
0
 
LVL 14

Expert Comment

by:Pierre Cornelius
ID: 39950096
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
 

Author Comment

by:ClaytonGlass
ID: 39950112
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
 
LVL 14

Expert Comment

by:Pierre Cornelius
ID: 39950229
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
 

Author Comment

by:ClaytonGlass
ID: 39950265
Thank you very much, Pierre. AsDate works.
0
 
LVL 14

Expert Comment

by:Pierre Cornelius
ID: 39950296
Glad to help. Good luck.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

721 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