Solved

records dated after today delphi

Posted on 2014-03-24
13
353 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
13 Comments
 
LVL 24

Expert Comment

by:jimyX
Comment Utility
Which Database you are using?
0
 

Author Comment

by:ClaytonGlass
Comment Utility
Paradox 7-11
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
what error do you get?
0
 
LVL 14

Accepted Solution

by:
Pierre Cornelius earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:ClaytonGlass
Comment Utility
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
Comment Utility
Thank you very much Pierre! And thanks to the other contributors, too.
0
 
LVL 14

Expert Comment

by:Pierre Cornelius
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you very much, Pierre. AsDate works.
0
 
LVL 14

Expert Comment

by:Pierre Cornelius
Comment Utility
Glad to help. Good luck.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now