0

I'm using SQLite, I want to get all the students who are having their DOB between 01-01-2000 and 12-12-2010. The dates are in TEXT and mm-dd-YY format in my database. I've done like this:

 SELECT * FROM student_details
  WHERE strftime('%m-%d-%Y', studentDob)
BETWEEN strftime('%m-%d-%Y', '01-01-2000')
    AND strftime('%m-%d-%Y', '12-12-2010')

But it is not giving any result even though the records are there in my DB. Please help me if there any wrong in my query. It not even producing any error.

1 Answers1

3

The American date format is inherently unsortable because units are not arranged in consistently increasing or consistently decreasing order. An ISO (Japanese) style date, however, can be sorted alphabetically making it the most superior of human-readable (and computer sortable) forms.

In the absence of a practical date format you have to convert that text string into something sortable, e.g. a Japanese form text string, or an integer.

For SQLite see Date and Time Functions.

For parsing date strings in SQLite see this StackOverflow answer.

Community
  • 1
  • 1
PP.
  • 10,764
  • 7
  • 45
  • 59