mysql怎么查询某天的数据
时间:2022-05-16 11:09
方法:1、用“date_format”函数,语法“where date_format(date,'%Y-%m-%d')='年-月-日'”;2、用datediff函数,语法“WHERE(datediff(time,'年-月-日')=0)”。 本教程操作环境:windows10系统、mysql8.0.22版本、Dell G3电脑。 1、DATE_FORMAT函数 WHERE(datediff(time,'年-月-日')=DATE_FORMAT() 函数用于以不同的格式显示日期/时间数据。 语法 date 参数是合法的日期。format 规定日期/时间的输出格式。 示例如下: 2、DATEDIFF函数 DATEDIFF() 函数返回两个日期之间的天数。 语法 date1 和 date2 参数是合法的日期或日期/时间表达式。 示例如下: 扩展知识: 推荐学习:mysql视频教程 以上就是mysql怎么查询某天的数据的详细内容,更多请关注gxlsystem.com其它相关文章!mysql怎么查询某天的数据
DATE_FORMAT(date,format)
select * from [table_name] where date_format([date_name],'%Y-%m-%d') = '2022-05-13'
DATEDIFF(date1,date2)
SELECT * FROM [table_name] WHERE ( datediff ( update_time , '2022-05-13' ) = 0 )
SELECT * FROM [table_name] WHERE substring(Convert(char(10),update_time ,112),1,8)='20220513'
SELECT * FROM [table_name] WHERE update_time between '2022-05-13 00:00:00' and '2022-05-13 23:59:59'
SELECT * FROM [table_name] WHERE year(update_time ) = 2022 and month(update_time )= 05 and day(update_time ) = 13
SELECT * FROM [table_name] WHERE update_time > '2017-09-27' and update_time < '2022-05-13'