Selecting a record one year old
I have records in MySQL base and each record has date field, it's of 'datetime' format. I want to select a record one year old and I'm currently having this:
$query_articles = "SELECT * FROM ".db('prefix')."articles WHERE published = 1 AND category!='1' AND SUBSTRING(position, 1, 1) != '2' AND (date<=DATE_SUB(NOW(), INTERVAL 1 YEAR)) order by date desc LIMIT 1";
A strange things happen here. It was working for two days and for I get the same article for three days now. Now is 11th and I have the article from January 8th for three days. I looked at MySQL manual and I found something like this:
date=DATE_SUB(NOW(), INTERVAL 1 YEAR)
but that returns nothing. That's why I came up with such a complicated query. If anybody has any idea about fetching a record one year old I'd be very grateful.
Subject
Written By
Posted
Selecting a record one year old
January 11, 2009 02:04PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.