On Thu, Oct 2, 2008 at 12:35 PM, Jason Pruim <japruim@xxxxxxxxxx> wrote: > Hi Everyone, > > I am working on a app where I need to be able to select all the values from > a database where the 'timein' field is between a certain date range... > Essentially the last 7 days... > > here is the code that I am working with: > > $rangeBegin = strtotime("Last week thursday midnight"); > $rangeEnd = strtotime("Today now"); > > > $SQLTEST = "SELECT * FROM `timeStore` WHERE `timein` BETWEEN > {$rangeBegin} AND {$rangeEnd}"; > echo "SQLTEST: " . $SQLTEST . "<br>"; > SQLTEST: SELECT * FROM `timeStore` WHERE `timein` BETWEEN > 1222315200 AND 1222920000 > Could not perform query: Query was empty > > All of my times are stored as unix timestamps in the database, such as: > > +------------------------------------------+ > | timein | timeout | empID | record | > +------------+------------+-------+--------+ > | 1222354037 | 1222382837 | 1 | 107 | > | 1222440437 | 1222469237 | 1 | 108 | > | 1222526837 | 1222555637 | 1 | 109 | > | 1222613237 | 1222642037 | 1 | 110 | > | 1222699637 | 1222728437 | 1 | 111 | > | 1222359217 | 1222359220 | 2 | 115 | > | 1222359214 | 1222359220 | 2 | 114 | > | 1222359219 | 1222359220 | 2 | 116 | > | 1222359231 | 1222359566 | 2 | 117 | > +------------------------------------------+ > > Anyone has any ideas? Or maybe a better way? :) > > -- > > Jason Pruim > Raoset Inc. > Technology Manager > MQC Specialist > 11287 James St > Holland, MI 49424 > www.raoset.com > japruim@xxxxxxxxxx > > > > > You can do this: $startTS = time() or mktime for today at midnight strtotime("-1 week", $startTs) and make your query use these params. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php