MySQL Forums
Forum List  »  Newbie

need to compare date between variable and mysql stored date
Posted by: ibakebread
Date: August 04, 2005 08:15PM

I have a page which receives a GET variable in the format: YYYYMMDD_HHMMSS. I need to compare it to the dates stored in the db. All of the dates are unique but they are generated by the DATETIME function in mysql and store in the format YYYY-MM-DD HH:MM:SS. I tried the following code:

$query = "SELECT title,author,type,text,link FROM news WHERE DATE_FORMAT(date,'%Y%m%d_%H%i%S') = $_GET[news_item] LIMIT 1";

I'm trying to format the stored date into the same format as the $_GET variable. I've printed out the varible separately, to test it, but I can't figure out how else to achieve this.

To change the format of the $_GET variable would involve too many changes. So it has to be similar to what I've tried.

thanks for your help.

Options: ReplyQuote


Subject
Written By
Posted
need to compare date between variable and mysql stored date
August 04, 2005 08:15PM


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.