我想显示当月内的结果
例如
选择* FROM table_name WHERE date ="这个月" ...
我可以用什么来代替这个月以获得当月的结果
答案 0 :(得分:1)
使用日期功能提取月份并与您尝试匹配的月份数量进行比较: -
Select * FROM table_name WHERE MONTH(date)= [0 - 11];
您可能需要与正确的年份匹配: -
Select * FROM table_name WHERE MONTH(date) = month(current_timestamp) and year(date) = year(current_timestamp);
答案 1 :(得分:0)
尝试此查询: -
Select * FROM table_name WHERE DATE_FORMAT(date_field,"%m")= DATE_FORMAT(NOW(),"%m");
答案 2 :(得分:0)
尝试此查询
select * from tableName
where month(dateField) = month(now())
and year(dateField)= year(now());