

CodePudding user response:
Just checked the online date functions in MySQL explanation, found the date function to extract the date only part, specific can consult this article: https://www.jb51.net/article/142737.htmCodePudding user response:
MYSQL's official handbook is one of the best free reference documents,CodePudding user response:
Said that is not a direct baidu search to find the official documentationCodePudding user response:
drop table if the exists ` test `;
The create table ` test ` (
` create_time ` datetime
);
Insert into ` test ` values (' 2018-11-22 14:14:34 ');
Insert into ` test ` values (' 2018-11-22 14:14:49 ');
Insert into ` test ` values (' 2018-11-22 14:18:40 ');
Insert into ` test ` values (' 2018-11-22 14:30:31 ');
Insert into ` test ` values (' 2018-11-22 14:32:57 ');
Insert into ` test ` values (' 2018-11-23 14:54:36 ');
Insert into ` test ` values (' 2018-11-24 16:27:15 ');
- # for above test data -
Select * from test
Where create_time between
Date (' 2018-11-22 18:17:33)
And
DATE_ADD (' 2018-12-19 18:17:33, INTERVAL 1 DAY)
;
In general, and should not be on the field after the where any function, it will affect the query efficiency,
Where the date (create_time) it is wrong,
To the packing, only the constant part behind the packaging,
CodePudding user response:
Create_time fields above, usually add index,But the date (create_time) will disable index,
CodePudding user response:
Behind the time, change to be similar to this appearance,03:04:05 STR_TO_DATE (' 2018-01-02 ', '% % Y - m - H: % d % % I: % s')