first of all, ‘Date Of Birth’ is a string, and you probably wanted it to be a column name
see, right away you ran into trouble because your column name has spaces in it, and you didn’t escape the name properly
so my advice is don’t get fancy, rename your column date_of_birth (no spaces) and you won’t have to worry ever again about properly escaping it
second thing wrong is that if it is an actual DATE column, then the values you’re passing to compare it to in your BETWEEN range are not valid mysql dates
valid mysql dates are always given in year-month-day sequence, e.g. ‘2009/09/09’, ‘2010-10-10’, ‘2011$11$11’ (you will notice that the separator can be any character)
What?
I noticed the spaces in the column name, and the normal quotes around them. But the OP said that query “work’s” (no errors), so I assumed he really uses backticks and just used normal quotes to post it here.
you would dictate the display format in your front end application language while obtaining the date as a date
a less attractive option is to use the the DATE_FORMAT mysql function to extract the date and arrange it into a custom string to pass back to the front end application language as a string
but to enter information into the database, and for specifying values e.g. in a WHERE clause range test, you must use year-month-day sequence in your sql
Yeah, r937 already explained why. It’s because ‘Date of Birth’ is a string, not a column name, so the query confronts two strings, and ‘Date of Birth’ is obviously never the same as ‘1990-01-01’, so it will return nothing.