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

Possible hard drive failure

Posted by howsthat, 01-12-2008, 01:49 PMI am getting this error on my mail from cpanel...

php website taking screenshots of other websites...

Posted by thomase, 09-08-2008, 04:29 PMI'd like to be able to take a screen shot, similar to the...

Packet Tracer - For Windows

Posted by josephgarbett, 03-05-2010, 11:55 AMHey All, I need to download Packet Tracer 5.0 - 5.2...

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...

Released Sql Server 2008 Express without SSMSE 08

Posted by IceDog, 08-18-2008, 12:27 AMI'm sure most of you know that they released the Sql Server...