[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Using date in WHERE clause in Informix
- Subject: Using date in WHERE clause in Informix
- From: "jayateerth.rp" <jayateerth.rp@MPHASIS.COM>
- Date: Thu, 3 May 2001 20:05:54 +0530
- Thread-Index: AcDT3fnfZrwrNz+kEdW44QBgZwC8DQ==
- Thread-Topic: Using date in WHERE clause in Informix
Dear Friends,
I want to extract all the records that were inserted for the day from a
table called "TABLE_NAME". The date on which the records were inserted
will be stored in a field called DATE. But since the database used is
Informix, the dates are stored in the format YYYY-MM-DD
HH:MI:SS.NNN.(i.e. It will contain both date and time)
The code, which I wrote to extract is as follows...
begin-program
do main
end-program
begin-procedure main
Let $date1 = datetostr($current-date,'MM/DD/YYYY')
begin-select
Let $date2 = datetostr(&a.DATE,'MM/DD/YYYY')
If $date1 = $date2
Do something
End-if
a.DATE
from TABLE_NAME a
end-select
end-procedure
But this is not efficient because I am extracting all the records and
then considering the for the day records.
I would like to use this condition in where clause to improve the
performance. So I changed my code like .....
begin-program
do main
end-program
begin-procedure main
Let $date1 = datetostr($current-date, 'MM/DD/YYYY')
begin-select
a.DATE
from TABLE_NAME a where
datetostr(a.DATE,'MM/DD/YYYY') = [$date1]
end-select
end-procedure
But I am getting errors while compiling. Can any one suggest me to
include date part in WHERE clause.
With Thanks,
Jay
.