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

Răspunsul a fost util?

 Tipărire

V-ar mai putea interesa și

Opening a new page in an iframe, is it possible?

Posted by bambinou, 02-09-2011, 01:49 PMHi All, I have an iframe here: In this iframe I...

Long "updating" state for mysql db. Does this indicate a problem?

Posted by mrzippy, 10-30-2012, 01:57 PMHello, I am working with a customer to try and help him...

clamscan command

Posted by persianwhois, 04-21-2009, 05:04 AMCan you please provide a clamscan ssh command for...

ASP.net vs PHP

Posted by porov, 03-01-2007, 03:06 AMWhat is better? I hear asp.net is better for large scale...

Merchant account

Posted by cass, 09-03-2002, 06:00 AMHi, Just joined to get advise on a merchant account for my...