There is a table with fields containing unix timestamps, and I was trying to get records that are older than one hour with
select * from table_name where (date('now','unixepoch') - table_field) > 3600
But this doesn’t show any records at all, but there are fields containing stamps of the time of days ago. If there is some simple condition like table_field > 1 it does output all the records. But why the statement at the top doesn’t work?
The
'unixepoch'modifier converts from a Unix timestamp number to a format that thedatefunction understands.However, you want to convert from a date string to a Unix timestamp:
Instead of counting seconds, you could also use a modifier (but without the subtraction, the string returned by
strftimeis not automatically converted into a number):