Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mysql query and date

Status
Not open for further replies.

martinb7

Programmer
Joined
Jan 5, 2003
Messages
235
Location
GB
hi, i was wondering if its possible to do something like this.

i want to select * from a table (bans) where the date is less than todays date + 7.

bascially i want to get everything thats within the current week hence date + 7;

username | endDate
fred 27/01/2004

any ideas?

thanx


Martin

Computing help and info:

 
Is this a php question or an SQL question?
The PHP code u need to connect and query a database, is in the manuel at The SQL would probably look something like this:
Code:
SELECT * FROM bans WHERE date < DATE_ADD($today, INTERVAL 1 DAYS)

You will need to use php to create the $today variable before querying the database:
Code:
$today = date(&quot;Y-m-d h:i:s&quot;);
 
It basically saying add one day to todays date... Looking back at your orginaly question I think I meant to put &quot;INTERVAL 7 DAYS&quot; for your problem. My bad, sorry.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top