Ask the mysql database for a field timestamp. how can I query data between different dates?

Source: Internet
Author: User
I have a field timestamp in the mysql database. how can I query data between different time ranges? mysql & nbsp; has a field Reg_addtime, which is the time value stored in the timestamp mode. How can I query, for example, the list of registered members from January 1, May 1, 2013 to January 1, May 10, 2013. I am not satisfied with a small dish. half a bottle is full. Give me some advice. I have a timestamp for a field in the mysql database. how can I query data between different dates?
Mysql has a field, Reg_addtime, which is the time value stored in the timestamp mode.

How can I query, for example, the list of registered members from January 1, May 1, 2013 to January 1, May 10, 2013.

I am not satisfied with a small dish. half a bottle is full. Give me some advice.
Share:
------ Solution --------------------
SELECT * FROM tbl_name WHERE FROM_UNIXTIME (Reg_addtime, '% Y-% m-% d') BETWEEN '2017-05-01' AND '2017-05-10'
------ Solution --------------------
You can also do this:

Select * from order where timestamp between UNIX_TIMESTAMP ('2017-05-01 00:00:00 ') and UNIX_TIMESTAMP ('2017-05-10 00:00:00 ');

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.