fetching data from SQLite database for specific time slot

Hafeez Niazi 1 Reputation point
2022-03-03T13:03:20.177+00:00

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?

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,808 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Ken Tucker 5,846 Reputation points
    2022-03-05T12:37:45.97+00:00
    0 comments No comments

  2. Rijwan Ansari 746 Reputation points MVP
    2022-03-05T17:37:54.703+00:00

    Hi @Hafeez Niazi

    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.

    0 comments No comments