How to write the query in mysql where i pass a date variable, it can list down all the date within that week.
etc. if i pass date = 6-12-2016, the query will print:
date
4-12-2016
5-12-2016
6-12-2016
7-12-2016
8-12-2016
9-12-2016
10-12-2016
How to write the query in mysql where i pass a date variable, it can list down all the date within that week.
etc. if i pass date = 6-12-2016, the query will print:
date
4-12-2016
5-12-2016
6-12-2016
7-12-2016
8-12-2016
9-12-2016
10-12-2016
You need to generate a Calendar Table like on this SO question:
And then run the following query:
SELECT *
FROM calendar_table
WHERE WEEK(date_column, 0) = WEEK('2016-12-06', 0);
This will produce output you want. 0 number in the argument describe mode in WEEK function. You can change the number to another number according to your needs. See MySQL Documentation about WEEK function.