Dates in PHP with MySQL
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 posted this at 17:31 — 26th January 2002.
He has: 4,048 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
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.