0

I am using SQLite and have a Trans_Date field that is stored as a text field. For various reasons, I want to leave the text values in that column as is. Here is the text format for that trans_date column:

m/d/yyyy h:mm:ss

Now, if I want to filter by a specific date, I can simply type in that string. However, the problem comes when I want to search a date range. The only way I can think of to do this is to filter by a list of date strings:

SELECT *
FROM LS2014
WHERE TRANS_DATE IN
('1/1/2014 0:00:00','1/2/2014 0:00:00','1/3/2014 0:00:00','1/4/2014 0:00:00')

Fortunately, I can create this string rather easily using Python or Excel's text functions, but I would much rather find a better way of doing this. Is there a better method for doing the same thing in SQL/SQLite?

timbram
  • 1,797
  • 5
  • 28
  • 49
  • 2
    possible duplicate of [Sqlite convert string to date](http://stackoverflow.com/questions/4428795/sqlite-convert-string-to-date) – Kritner Oct 01 '14 at 17:12
  • Ok, I took a look at that post and it would work but my textfield date values have 1 digit months and 1 digit days so the substring formula doesn't consistently work for me. Going to have to ask a question on that. – timbram Oct 01 '14 at 19:35

0 Answers0