Mysql queries data from one day, one week, and the other day _ MySQL

Source: Internet
Author: User
Mysql queries the data of bitsCN.com every other day for one day and one week.


Mysql queries data from one day, one week, and the other day

-- Query a day

Select * from tbl_order where date (tbor_create_time) = curdate ();

Select * from tbl_order where to_days (tbor_create_time) = to_days (now ());

-- Query a week

Select * from tbl_order where DATE_SUB (CURDATE (), INTERVAL 7 DAY) <= date (tbor_create_time );

-- Query a month

Select * from tbl_order where DATE_SUB (CURDATE (), INTERVAL 30 DAY) <= date (tbor_create_time );

-- Data between two dates

Select * from tbl_order where tbor_create_time> '2017-01-20 00:00:00 'and tbor_create_time <'2017-02-7 00:00:00 ';

BitsCN.com

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.