0

I need to generate a list of dates with MYSQl between two given dates and also, this list of the dates must to filter the dates that corresponds to Tuesday and Thursday days. Is it possible?

  • Check out the "related" column to the bottom right – Pekka Nov 19 '11 at 22:04
  • It would be great if you could provide us with the table structure so that any sql provided won't need too many changes on your end before you test. Also provide expected output samples as well :) – Nonym Nov 19 '11 at 22:05
  • possible duplicate of [Get a list of dates between two dates](http://stackoverflow.com/questions/510012/get-a-list-of-dates-between-two-dates) – Paul Tomblin Nov 20 '11 at 14:59

2 Answers2

0

In the meantime, here's a sample that you can use:

-- TO SELECT DATES IN A GIVEN RANGE
-- THAT DO NOT FALL ON A TUESDAY AND THURSDAY
SELECT dateColumn 
FROM yourTable 
WHERE DAYOFWEEK(dateColumn) NOT IN (3,5) 
    AND dateColumn BETWEEN '2011-01-01' and '2011-12-31';
Nonym
  • 6,199
  • 1
  • 25
  • 21
0

If you want the dates enumerated (not from your database) then see this link:

List of dates between two dates

You should be able to adjust the solution to filter for the desired day name using MySQL DayName function.

Community
  • 1
  • 1
NoChance
  • 5,632
  • 4
  • 31
  • 45