[Help] Current Time
Posted in 1999
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
We have a DATETIME(YEAR to MINUTE) field A. Now if I need to retrive all the records with: CURRENTTIME - field A < 2 hours i.e., records just being inserted within last 2 hours. Is there a way do it by using SQL, or I have to do it through ESQL/C. Thanks a lot!
Wang Chen wrote:
>
> We have a DATETIME(YEAR to MINUTE) field A.
> Now if I need to retrive all the records with:
>
> CURRENTTIME - field A < 2 hours
>
> i.e., records just being inserted within last 2 hours.
>
> Is there a way do it by using SQL, or I have to do it through ESQL/C.
SELECT * FROM atable
WHERE
(InsertTime + INTERVAL( 2 ) HOUR(1) TO HOUR) >= CURRENT YEAR TO MINUTE;
Art S. Kagel
Or simply:
where current - fieldA < 2 units hour
"Art S. Kagel" wrote:
>
> Wang Chen wrote:
> >
> > We have a DATETIME(YEAR to MINUTE) field A.
> > Now if I need to retrive all the records with:
> >
> > CURRENTTIME - field A < 2 hours
> >
> > i.e., records just being inserted within last 2 hours.
> >
> > Is there a way do it by using SQL, or I have to do it through ESQL/C.
>
> SELECT * FROM atable
> WHERE
> (InsertTime + INTERVAL( 2 ) HOUR(1) TO HOUR) >= CURRENT YEAR TO MINUTE> ;
>
> Art S. Kagel
________________________________________________________________
John H. Frantz Power-4gl: Extending Informix-4gl
john@rl.is http://www.rl.is/~john/pow4gl.html