PHP - MySQL Select Help

Posted by HostRefugee-Vince, 03-19-2007, 05:25 AM
Hi, I have a populated database with the date in the following format: 2007-01-28 YEAR-MONTH-DAY I want to run a SELECT statement that only grabs rows with a date older than or equal to 90 days from today's date. PLAIN TEXT SQL STATEMENT: SELECT plan FROM domains WHERE status='1' AND id='$appliestoID' AND dateActivated is older than OR equal to 90 days from today's date. Would someone be willing to translate that into valid php? The only part I am really having trouble with is the date part.

Posted by NastyPasty, 03-19-2007, 06:47 AM
Hi, abit rusty with the old mysql date selection methods, but I imagine you can use something like: SELECT plan FROM domains WHERE status='1' AND id='$appliestoID' AND dateActivated>=DATE_ADD(CURDATE(), INTERVAL -90 DAY) I'm sure this isn;t 100% correct, but this is along the lines of what you need. Dave.

Posted by jimpoz, 03-19-2007, 11:10 AM
Close. Either of the follwing should work: or

Posted by ak7861, 03-20-2007, 02:19 AM
Your field carrying the date should always be timestamped. Then you can easily call time() and subtract 90 x 24 x 60 x 60.

Posted by sergeysg, 03-20-2007, 05:43 PM
Another option is to use to_days() function: SELECT plan FROM domains WHERE status='1' AND id='$appliestoID' AND to_days(now())-to_days(dateActivated)>=90

Was this answer helpful?

 Print this Article

Also Read

suhosin and vbulletin

Posted by jon-f, 07-14-2007, 04:40 AMI have the max vars and all that set right to conform to...

Passive FTP Port Range Server 2008 Firewall

Posted by stooley, 04-21-2009, 09:13 AMDo you still have to add each port individually to Server...

Apache eating Memory

Posted by andrei155, 04-20-2009, 10:31 PMApache is wasting away a bit over a GB of memory at...

Is there a notepad type program that displays php code color format?

Posted by lexington, 09-01-2008, 09:38 AMHello, is there a (free script would be great) that acts...

pf Rule Question

Posted by fog, 01-13-2008, 07:35 PMCan someone tell me what's wrong with the following? (Besides...