Marco Bambini <[email protected]> wrote:
> I have a table Clients defined as (simplified version):
> CREATE TABLE Clients (id INTEGER PRIMARY KEY AUTOINCREMENT, last_activity
> TEXT, ping_timeout INTEGR);
>
> ping_timeout was a global property so in order to get a list of all clients
> timedout I used a query like (C code):
> snprintf(sql, sizeof(sql), "select id from Clients where last_activity <
> datetime('now', '-%d.00 seconds', 'localtime');",
> settings.ping_timeout);
>
> things are recently changed in my app and ping_timeout is now a client
> property set inside the Clients table (and no longer a
> global property), so I would like to perform the query using just the
> ping_timeout column in the Clients table instead of the
> settings.ping_timeout global property.
select id from Clients where last_activity < datetime('now', -ping_timeout || '
seconds', 'localtime');
-- or
select id from Clients where
(julianday('now', 'localtime') - julianday(last_activity)) * 86400 >
ping_timeout;
--
Igor Tandetnik
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users