1
Good morning, I need to return the sequence of the week of the month (of the reported period) in two fields, initial and final date. In PHP and MySQL.
Currently returns the week number in the year, follow print for 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:

edited by @Andersoncarloswoss
– wribeiro