Mysql groups the field time by day/month/year _ MySQL

Source: Internet
Author: User
The time field in the table is in the Unix timestamp format. you need to calculate the number of records per day based on this field and group the records by day, month, and year. assume that the table has a field time in the format of Unix timestamp, calculate the number of records per day based on this field.

Method:

Use the convert function convert (char (10), time, 120) as time, and then group by time.

Principle: The convert function converts the timestamp to the ODBC standard time (specified by the 120 parameter), takes the first 10 digits, and obtains the complete date (excluding the time, minute, and second), and then groups it.

The duration of the first parameter of the convert () method is the same as that of the yearly grouping method.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.