Selecting all records between a date range

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux