I'm creating a system for a school that needs to retrieve data from April of this year to June from last year.
I needed a query that can retrieve from this dates due to their school year always starts from June and end in April.
I tried selecting dates using Where clause.
"SELECT * FROM students WHERE year(c_date) = ? AND month(c_date) = ? AND c_occupation = 'Student'"
the question marks are use for java language which to prepare a statement using this code
pst=conn.prepareStatement(Sql);
pst.setInt(1, year);
pst.setInt(2, month);
I also tried this method but with this, I need to enter the date again after a year has pass.
SELECT users.* FROM users
WHERE dateadded <= '2019-06-01'
AND dateadded >= '2018-4-30'
I wanted it to automatically based on what today's year is.
So for example today is March 20, 2019. I should be able to return all the values from this day until June 1, 2018