lundi 2 février 2015

How to select all Mondays (or any day combo like MTW, WTTh) between two given dates in MySQL?


What I see over the internet is just counting how many days occur whenever you input the day of the week you need. Like between May 1 to May 31, how many mondays are there in it. What I need is to display the dates where it is monday between two given dates. I don't have any code for this now since I don't really know where to start as I've scanned already the MySQL docu but I haven't seen anything useful besides



WEEKDAY('1998-02-03 22:23:00')


or



DAYOFWEEK('1998-02-03')


which shows the day index of a certain date. (but this time, of course, I don't know which dates fall on Mondays., i need the reverse thing)


I need is when I need mondays and tuesdays in february, it will return the following:


2015-02-02 2015-02-03 2015-02-09 2015-02-10 2015-02-16 2015-02-17 2015-02-23 2015-02-24


I dont have any code to display since my progresses in mysql on our proj isn't directly related to this one I'm needing. This is another independent mysql query of our proj I'm trying to get done..





Aucun commentaire:

Enregistrer un commentaire