Solved

SQL Expression to get current date

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

16 Experts available now in Live!

Get 1:1 Help Now