Mysql groups the field time by day, month, or year.

Source: Internet
Author: User
Assume that the table has a time field in Unix timestamp format. You need to calculate the number of records per day based on this field. Method: Use the convert function convert (char (10), time, 120) astime, and then groupbytime. Principle: The convert function converts the timestamp to the ODBC Standard Time (specified by the 120 parameter), and then takes the first 10 digits, which is just better.

Assume that the table has a time field in Unix timestamp format. You need to 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), and then takes the first 10 digits, which is just better.

Assume that the table has a time field in Unix timestamp format. You need to 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.