date1 = 10/1/2015 date2 = 10/13/2015`
How to fetch data from database using these two dates? I want to fetch all the data that was entered from 1 to 13 october. How can I do it using php or SQL? Please guide me to write the SQL queries.
id name date 1 Ram 10/1/2015 2 shyam 10/2/2015 3 hari 10/13/2015 4 gita 10/14/2015</pre>
I want to select and show first 3 id which are listed between
1st oct to
13th oct and don't want to show 14th oct value. Please help me. Looking forward for the help. Thank you in advance. :)
Date format in MySQL is
yyyy-MM-dd. So, the query should be -
select * from test where date between '2015-10-01' and '2015-10-13';
If you want to use a different format to fetch your data then you can use
STR_TO_DATE. Your query will look like this.
select * from test where date between STR_TO_DATE('26-10-2012', '%d-%m-%Y') and STR_TO_DATE('28-10-2012', '%d-%m-%Y');