469,902 Members | 1,846 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,902 developers. It's quick & easy.

Comparing month and year from a timestamp

gregerly
192 Expert 100+
Hello, I've got a question regarding the comparison of a date and year to a timestamp. I've got blog entries that get a timestamp on their way into my database (mysql). I'm programming an "archives" section, and I can't seem to select the info using month and year. Basically what I want to do is say:

select all artices where the month of the timestamp = $given_month AND year of the timestamp = $given_year.

To accomplish the above I tried (note: blog_date is the timestamp in the db):

SELECT * FROM blog_entries WHERE MONTH(blog_date) = 'january' AND YEAR(blog_date) = 2009.

The error I'm getting is unknown column MONTH(blog_date), etc....

How do I go about selecting articles based on the timestamp when given the month and year of the article?

Thanks!

Greg

UPDATE: I've resolved the issue. It seems the CodeIgniter PHP framework likes to auto protect field names (and was doing so incorrectly) in my queries. I got it all worked out. Thanks!
Jan 7 '09 #1
0 1815

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Job Lot | last post: by
3 posts views Thread by Robert Dell | last post: by
1 post views Thread by DaveA | last post: by
3 posts views Thread by Bryan | last post: by
19 posts views Thread by Ricardo Perez Lopez | last post: by
2 posts views Thread by ameshkin | last post: by
12 posts views Thread by colincolehour | last post: by
3 posts views Thread by whatchamakeofit | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.