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

x
?
Solved

SQL Expression to get current date

Posted on 2002-07-19
5
Medium Priority
?
272 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
[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
  • 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

Industry Leaders: 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

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

722 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