Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8378007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:49:16+00:00 2026-06-09T15:49:16+00:00

This is my SQLite Database Table : +—-+———–+———-+ | ID | StartTime | EndTime

  • 0

This is my SQLite Database Table :

+----+-----------+----------+
| ID | StartTime | EndTime  |
+----+-----------+----------+
|  1 | 07:00:01  | 23:00:00 |
|  2 | 23:00:01  | 07:00:00 |
+----+-----------+----------+

Now I am having problem creating sql query to select them.

  • Time1=’14:00:00′

I used

SELECT * FROM 'table' 
WHERE StartTime <= '14:00:00'
AND EndTime >= '14:00:00';

Result for selecting Time1 returned is correct, I got what I want.

But

  • Time2=’07:00:00′
  • Time3=’06:00:00′

For Time2 and Time3, I can’t seems to determine what should be the SELECT statement conditions?

QUESTION

What should be the algorithm and SQLite statements to handle such situation, i.e. when it’s Time1, only ID 1 is returned, when Time2 and Time3, only ID 2 is returned?

I am using Java to execute SQLite statements, therefore I am not sure if all the functions are supported.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:49:18+00:00Added an answer on June 9, 2026 at 3:49 pm

    Here is an example query (SQLFiddle):

    select * from t where 
    (
    (StartTime<=EndTime) and 
     ('07:00:00' between StartTime and EndTime)
    )
     or
    (
    (StartTime>EndTime) and 
     ( 
        ('07:00:00' between StartTime and '23:59:59')
         or
        ('07:00:00' between '00:00:00' and EndTime)
    
     )
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings Overflowers, What is wrong with this PHP code: <?php define(DB_FILE, sqlite:database.sql); define(QUERY, INSERT
In this example we have 3 related tables on a SQLite database: CREATE TABLE
I get this error android.database.sqlite.SQLiteException: near %: syntax error: , while compiling: SELECT _id,
I have an sqlite database on android created like this: sqlite> .schema CREATE TABLE
In my application I have a sqlite database that looks like this: CREATE TABLE
I need to query a table in an SQLite database to return all the
So this is what I have, I have a SQLite database with 3 tables:
One of my tables in my SQLite database is returning this error code below:
This loop checks if a record is in the sqlite database and builds a
I successfully inserted some data into my sqlite database(I confirmed this by printing out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.