Subject Re: [firebird-support] X minutes ago
Author Arno Brinkman
Hi,

> I need to select the rows which have the TIMESTAMP field value more
> than X minutes ago from the current moment.
>
> SELECT * FROM VISIT_DETAIL
> WHERE (CHECKOUT_TIMESTAMP IS NULL) AND (CHECKIN_TIMESTAMP
> <= :CHECKIN_TIMESTAMP)

You check for both "IS NULL" AND a value which will never be the case. Didn't you meant OR?
Also i expect it to be (CHECKIN_TIMESTAMP >= :CHECKIN_TIMESTAMP)

> and then i popuplate the query parameter in Delphi application
>
> FQuery.ParamByName('CHECKIN_TIMESTAMP').AsDateTime := Now - X/(24*60);

Note that the client's datetime doesn't have to be the same as the server!

Regards,
Arno Brinkman
ABVisie

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
General database developer support:
http://www.databasedevelopmentforum.com

Firebird open source database (based on IB-OE) with many SQL-99 features:
http://www.firebirdsql.org
http://www.firebirdsql.info

Support list for Interbase and Firebird users:
firebird-support@yahoogroups.com

Nederlandse firebird nieuwsgroep:
news://newsgroups.firebirdsql.info