You can use between in the query
SELECT *
FROM employees
WHERE StartDate BETWEEN '1/1/2021' AND '1/1/2022';
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am trying to fetch data from the SQLite database for a specific time period like having a start date and end date. I am unable to find any possible solution for this. Can someone please guide me, on how I'll be able to do this?
You can use between in the query
SELECT *
FROM employees
WHERE StartDate BETWEEN '1/1/2021' AND '1/1/2022';
You can do select query from table as suggested by Mr. vb2ae. You need to have datetime column in your table.
Based on format, you do in following ways: (change table name and date column (in where condition) as per your one)
Sample 1. If you don't want to use between then.
select * from tableName where date >= '2022-02-09' and date <= '2022-03-01'
Sample 2: If date column is with timestamp then.
SELECT * FROM tableName WHERE date BETWEEN '2022-02-09 00:00:00' AND '2022-03-01 23:59:59'
Sample 3: If date column is date only then.
SELECT * FROM tableName WHERE DATE(date) BETWEEN '2022-02-09' AND '2022-03-01'
Sample 4: if it is text field then.
SELECT * FROM tableName WHERE DATE_FORMAT(date,'%Y-%m-%d') BETWEEN '2022-02-09' AND '2022-03-01'
Try these query, please let us know if helps you.