Query with mysql date

0

I have a table with a field of type TIMESTAMP , I want to perform a grouping query for the same day record, without taking into account the time. Is there a function of MYSQL for that type of data that does this?

    
asked by Islam Linarez 22.04.2017 в 23:06
source

1 answer

1

First, the date is extracted with the function DATE() , to keep only the date (without the time), and then we can group with GROUP BY according to that value. Then, COUNT(*) will return the number of rows per day.

SELECT
    COUNT(*) as cuantos,
    DATE(cuando) as dia
FROM 'tu_tabla'
GROUP BY dia

Documentation of the use of dates and time of Mysql

    
answered by 22.04.2017 в 23:11