Count equal dates select MySql

2

Hello, in a MySql database I have a table like this:

email | data_envio
  a   |2016-10-01 05:32:57
  b   |2016-10-02 09:36:56
  c   |2016-10-02 08:16:52
  d   |2016-10-03 10:36:51
  e   |2016-10-04 10:36:51

How do I make a select return for example the amount of submissions on 10/10/2016?

    
asked by anonymous 17.11.2016 / 17:22

1 answer

4

One option is to search for times between 00:00 and 23:59:

SELECT COUNT(email) AS quantidade
  FROM tabela
 WHERE data_envio BETWEEN '2016-10-02 00:00:00' AND '2016-10-02 23:59:59';

You can also use the DATE function to convert to data by ignoring the time information:

SELECT DATE(data_envio) as data_envio,
       COUNT(email) AS quantidade
  FROM tabela
 GROUP BY DATE(data_envio)
    
17.11.2016 / 17:27