mysql where语句日期问题 [英] mysql where statement date issue
本文介绍了mysql where语句日期问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
希望有人可以提供帮助,
hope someone can help,
我要尝试的是从数据库中提取给定月份的所有结果, 仅使用mysql查询(不使用php)是可能的.
What i`m trying to do is pull all results from the database for any given month, Is the possible using a mysql query only (no php).
我正在使用具有我唯一访问权限的模板应用程序,是通过mysql where语句,因此,我需要从"2013-04-01"中计算出月份是多少,如果需要,请抓住它.
Im using a template app with the only access i have is through i mysql where statement, So i need to work out from "2013-04-01" what the month is and grab it if its the one i want.
下面的代码有效,但显然也将2013年与我联系在一起.
The code below works but obviously ties me too the 2013 year.
`SELECT * FROM table_name WHERE Display_Date => 2013-04-01 AND Display_Date <= 2013-04-30 LIMIT 10`
推荐答案
SELECT
*
FROM
table_name
WHERE
MONTH(Display_Date) = MONTH(CURDATE())
AND YEAR(Display_Date) = YEAR(CURDATE())
参考
这篇关于mysql where语句日期问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文