I have a table with below structure and data.
id ean Control_date qty
1 4046228081410 26.05.2017 568
2 4046228081410 05.06.2017 900
My expected result would be like below
2 4046228081410 05.06.2017 1468
To acheive this i am using the below query
SELECT EAN,Control_date,SUM(Qty) AS Qty FROM mytable WHERE
(STR_TO_DATE(`Control_date`,'%d.%m.%Y') <= STR_TO_DATE('03.06.2017','%d.%m.%Y')
OR
STR_TO_DATE(`Control_date`, '%d.%m.%Y') <= DATE_ADD(STR_TO_DATE('03.06.2017', '%d.%m.%Y'), INTERVAL 7 DAY))
AND ean = 4046228081410
Here i need to sum up the qty where control date< today date and control date > today date and should be less than todaydate + 7 days . Here 2nd control date is 05.06.2017 and greater than today date and less than (03.05.2017 +7 days) But always i am getting where contorl date is less than today date.
1 4046228081410 26.05.2017 1468
But i need data with control date 05.06.2017. Any help would be greatly appreciated.
datedata type, not a string. - Gordon Linoff