Ezilon.com - Target Your Audience, be Seen in Your Region

Dates in PHP with MySQL

You are viewing this site as a guest. Join our community to get your questions answered and share knowledge. Active members may advertise and ask for a website critique.

They have: 66 posts

Joined: Aug 2001

Hey guys,

I was wondering and I can't seem to find the way how to do this but it has to be done!

I am running a mysql table (called hunters) in hunters there is a date of a submission (timestamp, yyyymmddhhmmss).

I only want the script to pull out dates from the database that are no more that 30 days old.

How can I do this?

Thanks,
Adam.

Mark Hensler's picture

He has: 4,044 posts

Joined: Aug 2000

SELECT * FROM table_name WHERE TO_DAYS(NOW()) - TO_DAYS(date_col) > 30

mySQL Docs: 6.3.4 Date and Time Functions

Mark Hensler ["Max Albert"] [Email]
If there is no answer on Google, then there is no question.