Selecting all records between a date range



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






Relevant Pages

  • Re: How much time does a query take?
    ... not only the MSDE running, but also a visualisation for a part of a ... tell our app when a fault occured und when it went away. ... the app would execute a query against the database to retrieve the ... Like I wrote in my first question, in that way there can be a query every ...
    (microsoft.public.sqlserver.msde)
  • Re: DBMS and lisp, etc.
    ... Naively implemented with SQL, again for 10 ... (1 query for the initial orders, 1 query for each order for its ... soon as you upgrade to the SQL database. ... (eq (order-customer orderA) ...
    (comp.lang.lisp)
  • Re: Relationships. Does anyone use them?
    ... make maintaining the database a nightmare, and leave you still uncertain you ... After that first app I didn't do relationships. ... If I had a query, ... I cared not about cascading deletes or cascading updates or the type of ...
    (comp.databases.ms-access)
  • Re: OT: SQL
    ... query processing. ... FROM Employees e, Employees m, Management mgt ... Manager and Employee Salaries. ... The scheme used does not model database files in general, ...
    (sci.logic)
  • Re: access 2003
    ... I removed the parameters from the form query source. ... boxes from the form header, events, code, etc and ran the form query source ... forms queries and the SQL because syntax of the SQL will change randomly. ... the Access 97 database, I wouldn't have thought any expressions would be ...
    (microsoft.public.access.conversion)