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 James Jun 18 '19 at 13:22

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. – kulpreet singh Jun 18 '19 at 9:55
  • 1
    Can you post the full query? Also this answer may help: stackoverflow.com/questions/4727002/… – KevH Jun 18 '19 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.