How to locate the data of the respective month

Asked

Viewed 33 times

0

I would like to know how to get only the data of the respective month in which we are.

For example: I have the date 2017-05-10 and I have the date 2017-11-05, how do I take data only from a date with Mysql. I only want data from the date 2017-11-05, then it returns to me all the data that are on that date, how can I do it?

What I have so far:

mysqli_query($sql, "SELECT data, sum(total) FROM pedidos";

2 answers

0


I believe that’s what you’re looking for:

mysqli_query($sql,"SELECT data, sum(total) FROM pedidos WHERE date like '%" . date("Y-m") . "%'");
  • and that there just need to adapt in my case would n date and yes data but that’s what helps

  • Imagine @robertaEDG ;)

0

Do so:

mysqli_query($sql, "SELECT data, sum(total) FROM pedidos where data >=" . date('Y-m');

  • That’s not it. Let’s assume I have that by always picking up the current month we’re in $mes = date('Y-m') he will return me 2017-11 I want him to take this 2017-11 which is the year and month and check if there is any date in the database corresponding to this if there are list which are with their respective data

  • I edited the answer with the Cód that will help you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.