SQL statements have been learned before in school. After a long time, I cannot remember them.
SQL statements have been learned before in school. After a long time, I cannot remember them.
Today, we use the time Like '2017-06-2008 'statement to query all the data of the day. A statement error is prompted. After checking, we found that the fuzzy query can only be used for fields of the String type.
I also consulted some materials. There are three methods for fuzzy query of time:
1. Convert to String and use Like to query.
Select * from table1 where convert (varchar, date, 120) like '2017-04-2006'
2.
Select * from table1 where time between '2017-4-1 0:00:00 'and '2017-4-1 24:59:59 '";
3 datediff () function
Select * from table1 where datediff (day, time, '2017-4-1 ') = 0
The first method should be applicable to any data type;
The second method is applicable to types other than String;
The third method is a more practical and quick method customized for the date type.