SQLite Queries for dates

Posted by user2909616 on Stack Overflow See other posts from Stack Overflow or by user2909616
Published on 2013-10-25T03:46:33Z Indexed on 2013/10/25 3:54 UTC
Read the original article Hit count: 76

Filed under:
|

I have a SQLite data base which I am pulling data for a specific set of dates (lets say 01-01-2011 to 01-01-2011). What is the best way to implement this query into SQL. Ideally I would like the following line to run:

SELECT * FROM database where start_date < date_stamp and end_date > date_stamp

This obviously does not work when I store the dates as strings.

My solution (which I think is messy and I am hoping for another one) is to convert the dates into integers in the following format: YYYYMMDD Which makes the above line able to run (theoretically). IS there a better method?

Using python sqlite3

Would the answer be any different if I were using SQL not SQLite

© Stack Overflow or respective owner

Related posts about python

Related posts about sqlite