Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fetching Data based on the day

Status
Not open for further replies.

Soheils

Programmer
Mar 27, 2002
1
US
Hello everyone.
I am trying to extract the data from MySQL based on the month, and day of
the item, and post them on a page.
Something similar to "Today in History"
Here is a partial list of my table:
CREATE TABLE ANNOUNCEMENT (
AnnouncementID bigint(20) unsigned DEFAULT '0' NOT NULL,
Title varchar(250),
DateShown date DEFAULT '0000-00-00' NOT NULL
KEY AnnouncementID (AnnouncementID),
KEY ID (AnnouncementID)
);
Can anyone please tell me what I need to do?
Here is what I have so far:
SELECT AnnouncementID,Title,DateShown FROM ANNOUNCEMENT WHERE
DateShown=NOW() ORDER BY DateShown DESC

The problem is that it matches the list to the entire date (including the
year), but I only want to look at the month, and the day, when fetching the
data.

Thanks so much.
 
Soheils, you could try converting DateShown to a text string and comparing the last so many characters with the equivalent from today's date.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top