Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sqlite SELECT * for Last 7 days

Im trying to do a SELECT * to retrieve rows for last 7 days in SQLite.

the table structure is as follows

CREATE TABLE 'session' ('rowID' INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL , 'steps' INTEGER, 'stop_time' DATETIME NOT NULL  DEFAULT CURRENT_TIMESTAMP)

How do I do this? Im new at this

like image 938
Jason Avatar asked Sep 03 '10 09:09

Jason


People also ask

What is wildcard in SQLite?

SQLite provides two wildcards for constructing patterns. They are percent sign % and underscore _ : The percent sign % wildcard matches any sequence of zero or more characters. The underscore _ wildcard matches any single character.

What is Strftime in SQLite?

The SQLite strftime function is a very powerful function that allows you to return a formatted date as well as perform date calculations on that date. This function returns the date as a text representation.

What is the use of date () function in SQLite?

The SQLite date() function is used to calculate the date and return it in the format 'YYYY-MM-DD'. The SQLite datetime() function is used to calculate a date/time value, and return it in the format 'YYYY-MM-DD HH:MM:SS'. The SQLite julianday() function returns the date according to julian day.


1 Answers

SELECT * FROM session WHERE stop_time > (SELECT DATETIME('now', '-7 day'))

Refer to the documentation

like image 119
falconcreek Avatar answered Oct 27 '22 03:10

falconcreek