Re: HELP - How to Do this Query?
Posted in 1997
Yan Liu wrote:
>
> We have a DATE field of a table. Now I need to select all the records
> around a day. For example between "97/10/10" - 10 days and "97/10/10" +10 days.
> How shall I write the WHERE statement?
>
> I know it would be easy for a datetime field by using 10 UNITS DAY.
> But what to do for DATE field? Any body have any ideas? Thanks!
What are you using for a front-end tool? ESQL/C? 4GL? DBACCESS?
The answer depends. In ESQL/C convert the string date to a date
variable which is stored as an integer number of days since 12/30/1899.
Then just copy basedate-10 into lowerbound and basedate+10 into
upperbound and:
select ....
from ...
where datefield between :lowerbound and :upperbound;
In 4GL you can do the same but you need to write a 4GL callable "C"
function to do the arithmetic. In DBACCESS you must do the date
calculations yourself. Hope that helps.
Art S. Kagel