I have a table datedim
which has all the dates of a month in it. I have another table attendance
that has dates on which attendance were taken. I need to write a query where i can get all the dates from the start till current.
For eg. if attendance table has records starting from 3-Apr-2019 to 3-June-2019, i should get all the dates in between them.
-
Please provide sample input and output.– Rick JamesCommented Jun 18, 2019 at 13:22
1 Answer
You can use the BETWEEN conditional operator to search for anything in a range. The BETWEEN operater is inclusive so will find records for the start and end dates too.
You will be able to query the attendance
table directly:
SELECT * FROM attendance WHERE attendancedate BETWEEN '2019-04-03' AND '2019-06-03'
This question has some examples: https://stackoverflow.com/questions/3822648/how-do-i-query-between-two-dates-using-mysql
I hope that helps!
-
Hi, Thanks for the response. But the problem i am facing is i have around 100 such records of the start date and end date so i cannot apply between for 100 of such dates. I used where date between min(attendancedate) and max(attendancedate) but i got error 1111.invalid use of group function. Commented Jun 18, 2019 at 9:55
-
1Can you post the full query? Also this answer may help: stackoverflow.com/questions/4727002/…– KevHCommented Jun 18, 2019 at 10:29