MySQL uses the Date_format method to achieve statistics daily/monthly new users

Source: Internet
Author: User

To implement statistics for new users daily or monthly, but the time that is stored in the database is a timestamp, so use the Date_format function

Data for database table storage:


To count the new users of the day, format the timestamp format as an adult-month-day form and group by the field in Format (group by), counting the Count

SQL statements:

SELECT date_format (create_time, '%y-%m-%d ') as time, COUNT (*) as Count from Tb_users GROUP by Time  
Query Result:

Specific usage of Date_format

Http://www.w3school.com.cn/sql/func_date_format.asp



MySQL uses the Date_format method to achieve statistics daily/monthly new users

Related Article

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.