Selecting all records between a date range
- From: japruim@xxxxxxxxxx (Jason Pruim)
- Date: Thu, 2 Oct 2008 12:35:47 -0400
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
- Follow-Ups:
- Re: [PHP] Selecting all records between a date range
- From: "Eric Butera"
- Re: [PHP] Selecting all records between a date range
- From: "Dan Joseph"
- Re: [PHP] Selecting all records between a date range
- From: Jim Lucas
- Re: [PHP] Selecting all records between a date range
- From: Per Jessen
- Re: [PHP] Selecting all records between a date range
- Prev by Date: Re: [PHP] SESSION array problems [THE REASON]
- Next by Date: Re: [PHP] Selecting all records between a date range
- Previous by thread: RE: [PHP] SESSION array problems
- Next by thread: Re: [PHP] Selecting all records between a date range
- Index(es):
Relevant Pages
|