I have a database table with date field whose data type is also date and i want to fetch those recods which lie betwnn two dates.
My query is :
SELECT * FROM wp_races_entry WHERE date_in >=2012-02-08 && date_in<=2012-02-27
i also tried
SELECT * FROM wp_races_entry WHERE date_in BETWEEN 2012-02-08 AND 2012-02-27
i have records in table with date 2012-02-14 but still it return empty value.
Please help me guiding what i am missing exactly.
You need quotes round your dates:
SELECT * FROM wp_races_entry WHERE date_in BETWEEN '2012-02-08' AND '2012-02-27'
Without the quotes your dates are treated as arithmetic expressions: 2012-02-08 = 2002.
The query you posted is equivalent to this:
SELECT * FROM wp_races_entry WHERE date_in BETWEEN 2002 AND 1983
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With