MySQL queries the day before data

Source: Internet
Author: User

How does the MySQL database query data for the previous day based on time? This article has sorted out several solutions that are needed by a friend under reference.

The content of this section:
How to use MySQL to query the data of the previous day based on time.

Example 1:

code Example:SELECT * FROM TT where F1=DATE_ADD (today (), INTERVAL-1 Day)

Example 2:

code Example:SELECT * from the TT where F1 between Date_sub (Curdate (), INTERVAL 1 day) and current_date ();

Example 3,mysql time query.

code Example:SELECT * FROM TT
Where F1 >= date_sub (Curdate (), INTERVAL 1 day)
and F1 < Current_date ();

Example 4,mysql time query.

code Example:SELECT * FROM Tig_users
where date (Last_login) =curdate ()-interval 1 DaySelect Date_sub (now (), Interval 1 day);Adddate (now (),-1) can also achieve the effect

MySQL queries the day before data

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.