I'm trying to translate the PostgreSQL query:
SELECT * FROM mytable
WHERE last_check_timestamp + (INTERVAL '1 seconds')*interval_seconds <= now()
to an equivalent query in SQLite.
What I'm getting stuck on is how to dynamically create dates/intervals based on table columns. What's the equivalent to "INTERVAL" in SQLite?
See the date and time functions for SQLite. You can say this to add 1 second to a datetime value for instance:
select datetime(last_check_timestamp, '+1 second')
A full implementation of your example query might look something like this:
select * from mytable
where datetime(last_check_timestamp,
'+' || interval_seconds || ' second') <= datetime('now','localhost');
Demo: http://www.ideone.com/lbp3G
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With