last day (15 days later) » 

12:39 PM
1
A: get the sum of datas in the same date and get an array for weekly reports

Zaynul Abadin Tuhinuse aggregation and convert date time to date by using DATE_FORMAT function select DATE_FORMAT(date_stamp, '%M %D %Y') as date_stamp,sum(amount) as amount from table_name where date(date_stamp)>= date(now()) and date(date_stamp)<= date(now()-6) group by DATE_FORMAT(date_stamp, '%M %D %Y')

 
the date is in datetime format in my database
 
@Remaster i have added your appropriate format
 
It works, but I want to only get the dates that ranges today and 6days before (making it a week) so the maximum data I will have is 7
 
@Remaster ok just need where condtion i going to put that please accept if it helps
 
it returned an error "Unknown column 'now' in 'where clause'"
 
12:39 PM
@Remaster check now there was a typo i missed ()
 
thankyouuuuuuuu
 
do an upvote as well mate
 
sure thing mate, can I ask one last thing?
 
12:57 PM
how can I echo it with a separator " , " ?
i tried using this one
GROUP_CONCAT(CONCAT('''', date_stamp, '''' ))
but it just returns an error
 
just use group_concat(date_stamp,',')
 
thanks mate, can you upvote my post as well?
 
thanks mate
should i do it after the alias?
like so
AS group_concat(date_stamp,',')
 
not understand
plz full query
what you done
 
1:10 PM
SELECT group_concat(DATE_FORMAT(datesales, '%M %D %Y'),',')
as datesales,sum(amount) as amount from sales
where date(datesales)>= date(now()) and date(datesales)<= date(now()-6)
group by DATE_FORMAT(datesales, '%M %D %Y')
the data it returns is " November 12th 2019,,November 12th 2019, "
instead if just " November 12th 2019 "
 
yap
you are doing correct
 
my database contains only 3 rows. all of them is of the same date, so shouldn't it return like this?

November 12th 2019 2999
2999 is the sum(amount)
 
 
3 hours later…
3:57 PM
plz
share details in dbfiddle
and expected output
 

last day (15 days later) »