Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
Art S. Kagel — — source: Informix-list mailing list archive (1991-1998)
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
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.