Num rows help

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Num rows help

Post by icesolid »

I have a MySQL database that has a field named date_ordered

I want to count the number of rows that exist AFTER 17 days older than todays date (older than 17 days). The code that I have put in below shows how I am attempting to do this now. I have no errors in the code, however the query is just telling me how many cases exist between ex: 2007-01-30 AND 2007-02-16. I want to know how many rows exist after ex: 2007-01-30

Code: Select all

<?php
$start_date1 = strtotime("-17 day");
$start_date1 = date("Y-m-d", $start_date1);
$end_date = date("Y-m-d");

echo mysql_num_rows(mysql_query("SELECT * FROM cases WHERE location_territory='Bronx' AND assigned='false' AND date_ordered BETWEEN '$start_date1' AND '$end_date'"));
?>
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Post by GeXus »

You can do greater than.. so

Code: Select all

SELECT * FROM cases WHERE location_territory='Bronx' AND assigned='false' AND date_ordered > '$end_date'
Post Reply