Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL Expression to get current date

Posted on 2002-07-19
5
Medium Priority
?
275 Views
Last Modified: 2010-04-04
I'm trying to run a query in a QReport that selects rows based on the current date and time, as in

SELECT * FROM Calls
WHERE ((DeadlineDate < ??CurrentDate??) OR ((DeadlineDate = ??CurrentDate??) AND (DeadlineTime < ??CurrentTime??))

Any ideas as to what should go between the ??'s? I've tried things like GetDate() and SYSDATE to no avail.

Cheers
0
Comment
Question by:riccohb
  • 3
  • 2
5 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7164821
SELECT * FROM Calls
WHERE ((DeadlineDate < :Date1) OR ((DeadlineDate = :Date2) AND (DeadlineTime < :Time1))

depending of the type of fields, i guess its date-type

query1.close;
query1.parambyname('Date1').AsDateTime := Trunc(now);
query1.parambyname('Date2').AsDateTime := Trunc(now);
query1.parambyname('Time').AsDateTime := Frac(now);
query1.open;

meikl ;-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7164823
oops, :time should be :time1 ;-)
0
 

Author Comment

by:riccohb
ID: 7164965
Thanks for that Meikl, but I'm getting a 'type mismatch in expression'. It works fine if I leave out the Time part of the expression/code. The table I'm working on was created in Database Desktop. The date fields are type 'Date' and the time field is type 'Time'.

Can you help?

I'm very grateful for your time.
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 200 total points
ID: 7164980
hmm maybe this change helps

instead of
query1.parambyname('Time').AsDateTime := Frac(now);

use
query1.parambyname('Time').AsTime := Frac(now);
or also
query1.parambyname('Time').AsTime := now;

hope this helps

meikl ;-)

0
 

Author Comment

by:riccohb
ID: 7165047
Perfect. Thanks,
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

885 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