Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to query today's data with mysql

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article focuses on "how to use mysql to query today's data", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to query today's data with mysql.

In mysql, you can use select statements in conjunction with "to_days ()" and now () functions to query today's data, with the syntax "select * from table name where to_days (time field name) = to_days (now ());".

The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.

How does mysql query today's data?

If mysql wants to query today's data, he can use the select statement to query today's data with the TO_DAYS function and the now function.

The MySQL database uses SQL SELECT statements to query data.

TO_DAYS (date)

Given a date date, returns a date number (days since 0 years).

NOW () returns the current date and time.

Grammar

NOW ()

The syntax for querying today's data is:

Select * from table name where to_days (time field name) = to_days (now ())

Expand:

Yesterday

SELECT * FROM table name WHERE TO_DAYS (NOW ())-TO_DAYS (time field name)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report