Home>
SELECT
  COUNT (t)
FROM
  App.Data1 AS t
GROUP BY
  DATE_FORMAT (DATE_TIME, '% Y% m% d');
Write

and SQL statement and execute
An error occurred with Unrecognized function date_format.
If i look at the error, you can see that this error occurred because there is no DATE_FORMAT function in SQL? MySQL? How can I count the number of records per month? How should I modify the SQL statement?

sql
  • Answer # 1

    I don't know the situation, but your RBD is MySQL?
    date_format is available?

    select date_format ('2018-01-02 11:22:33', '% Y-% m-% d');
    select date ('2018-01-02 11:22:33');


    Same result as above, date_format can format dates into strings in more formats

  • Answer # 2

    MySQL :: MySQL 5.6 Reference Manual

      

    DATE (expr)
      Extracts the date part of a date or datetime expression expr.

    Since it is

    , is it OK to GROUP BY with the DATE ()?

    If you rewrite at the desktop debug level

    SELECT
      DATE (t. Date/time data column to be rounded) AS "DATE", COUNT (t) AS "COUNT_DATE"
    FROM
      App.Data1 AS t
    GROUP BY
      DATE (t. Date/time data column to be rounded);