For example, to query yesterday's newly registered users, there are two ways to write it: EXPLAIN select * from chess_user u where DATE_FORMAT(u.register_time,'%Y-%m-%d')='2018-01-25'; EXPLAIN select * from chess_user u where u.register_time BETWEEN '2018-01-25 00:00:00' and '2018-01-25 23:59:59'; The Attach date conversion function DECLARE yt varchar(10); #Yesterday DECLARE yt_bt varchar(19); #Yesterday's start time DECLARE yt_et varchar(19); #Yesterday's end time #Set variables SET yt=DATE_FORMAT(DATE_ADD(now(),INTERVAL -1 day),'%Y-%m-%d'); SET yt_bt=DATE_FORMAT(DATE_ADD(now(),INTERVAL -1 day),'%Y-%m-%d 00:00:00'); SET yt_et=DATE_FORMAT(DATE_ADD(now(),INTERVAL -1 day),'%Y-%m-%d 23:59:59'); Summarize The above is the optimization technique of Mysql querying date based on time introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: A brief discussion on several specifications of JS front-end modularization
>>: How to mount a new disk on a Linux cloud server
Uninstall tomcat9 1. Since the installation of To...
K8s k8s is a cluster. There are multiple Namespac...
Detailed explanation and summary of the URL for d...
In the Linux system, environment variables can be...
transform and translate Transform refers to trans...
This article describes the linux system commands....
In the process of making web pages, we often use f...
Table of contents 1. What is an event? 2. How to ...
In actual project development, if we have a lot o...
Data cleaning (ETL) Before running the core busin...
This article shares with you the solution to the ...
Object.defineProperty Understanding grammar: Obje...
Table of contents question extend Solving the pro...
<br />Before browsers can handle the next ge...
Achieve results Implementation Code html <div ...