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
Table of contents 1. Overview of Docker consul 2....
The img tag in XHTML should be written like this:...
Scenario: The interaction methods between parent ...
This article shares a draggable login box impleme...
need: The official website's resource server ...
React native implements the monitoring gesture to...
Table of contents Preface Several common bit oper...
These introduced HTML tags do not necessarily ful...
The first point to make is that people can judge t...
Table of contents What is an index? Leftmost pref...
nbsp   no-break space = non-breaking spa...
This article uses examples to illustrate the prin...
Overview For small and medium-sized projects, joi...
This article example shares the specific code of ...
1. Installation Install using yum ##Automatically...