Results 1 to 4 of 4
Thread: Question about date function
Oct 15, 2009, 15:35 #1
Question about date function
I have a table that stores articles with columns article, article_date
the article_date is in the date format 0000-00-00
What is the best way to select all articles that are NOT from the current month?
Oct 15, 2009, 16:36 #2
- Join Date
- Jul 2002
- Toronto, Canada
- 52 Post(s)
- 2 Thread(s)
you will get a good discussion about which approach is "best"
this one is simple and correct, but might not be efficient
WHERE EXTRACT(YEAR_MONTH FROM article_date) = EXTRACT(YEAR_MONTH FROM CURRENT_DATE)Code:
WHERE article_date < '2009-10-01' OR article_date >= '2009-11-01'
Oct 18, 2009, 06:13 #3
OK, if I can generate the year-month string with php, then I was thinking of this sql:
WHERE article date NOT LIKE '2009-09%'
I think this will work best. Since the LIKE condition does not start with %, the mysql will be able to use the index, so it will get result fast.
Oct 18, 2009, 09:05 #4
In my opinion, maybe you can have a try of RAQ Report. As I know, it provides a complete set of date time functions.
freezea.RAQ Report: Web-based Excel-like Java reporting tool.