Ishmael Chibvuri
Ishmael Chibvuri

Reputation: 441

Checking if a Date falls within a Range of Dates in SQLITE

I have an sqlite table with with 2 date columns (beginning & end). I am looking for a query that returns the date range a date falls in. e.g Checking range where 10-02-2016 falls given 2 records as follows

(01-02-2016  -  12-02-2016) & (13-02-2016  -  20-02-2016)

Clearly it falls in the first range but how do I do it in SQLITE. Please help?

Upvotes: 0

Views: 248

Answers (1)

Orest
Orest

Reputation: 6748

I think the problem is next SQLite requires dates to be in format YYYY-MM-DD. With that format you could write a simple query:

select * from table where yourdate between begin and end

If you can't change your format you should look at next sqlite functions https://sqlite.org/lang_datefunc.html

Also you can try substr function to cotact date in needed format.

Upvotes: 1

Related Questions