Reputation: 11
I have a table named revenue and has a column named datedone
(DATETIME
)
I wanted to group my records by day
, week
, and month
depends on the value of datedone
for e.g.
ID: 1 | rate: 99.99 | datedone: 2019-11-02 04:11:22
ID: 2 | rate: 99.99 | datedone: 2019-10-31 13:20:26
ID: 3 | rate: 99.99 | datedone: 2019-11-02 04:07:39
Here is query that I tried:
$sql = "SELECT * FROM revenue WHERE datedone = '$month' GROUP BY MONTH(datedone)";
But it return me this
ID: 2 | rate: 99.99 | datedone: 2019-10-31 13:20:26
ID: 3 | rate: 99.99 | datedone: 2019-11-02 04:07:39
What I want is display all the records for specific month, for example if I want to choose the month of november
It should display all the records that the values of datedone
has a november
month, same with day and week.
Upvotes: 0
Views: 241
Reputation: 2031
If you want all the rows from november, you'd have do do this:
SELECT * FROM revenue WHERE MONTH(datedone)=11;
Upvotes: 1