Good morning, I need to return the sequence of the week of the month (of the reported period) in two fields, start date and end date. In PHP
and MySQL
.
Currently returns the number of the week in the year, follow print for a better understanding.
SQL code:
SELECT YEAR(dadf331.datlan) AS ano,
MONTHNAME(dadf331.datlan) AS mes,
WEEK(dadf331.datlan) AS semana,
SUM(totped) AS totalv
FROM dadf331
WHERE tipped = 0
AND datlan >= '2017-09-01'
AND datlan <= '2017-09-30'
GROUP BY semana
ORDER BY semana ASC
Expected result: