发布日期:2023-03-31来源:武汉北大青鸟武汉校区作者:admin
记录一些常用的mysql日期函数
1、查询当天数据
sql = 'select * from article where add_time = CURDATE()'
2、查询昨天数据
sql = 'select * from article where to_days(now()) - to_days(add_time) = 1'
3、查询指定周的数据
$week_index = date("W")
sql = "select * from article where WEEKOFYEAR(add_time) = $week_index"
4、查询指定月的数据
$month_index = date('m')
sql = "select * from article where MONTH(add_time) = $month_index"
Copyright (c) 2006-2023 武汉宏鹏教育咨询有限公司 版权所有 All Rights Reserved.