gomes
gomes

Reputation: 15

SQLite SELECT all for Last 7 days

I can't return the last seven days in my sql query it only returns records from the previous month of the current month does not return records. Below my query works, but not as I wanted it only brings a record of the previous month of the current month does not bring the records.

SELECT * FROM processos where dt_alteracao > (select strftime('%d/%m/%Y %H:%M:%S', 'now' , '-7 days'));

Image of query result

Upvotes: 1

Views: 1478

Answers (1)

forpas
forpas

Reputation: 164089

If your column has the format YYYY-MM-DD hh:mm:ss then you can do it with the function datetime():

SELECT * FROM processos 
where dt_alteracao > datetime('now' , '-7 days');

Upvotes: 1

Related Questions