Solved

SQL Expression to get current date

Posted on 2002-07-19
5
270 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 50 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month10 days, 9 hours left to enroll

631 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