Click to See Complete Forum and Search --> : 2 dates as Criteria For Query


jsbert
06-12-2009, 06:26 PM
Hi,

I'm not to sure how to accomplish the following:

I need to retrieve specific information from 2 tables using 2 different dates as my search criteria. Then sum the amounts within they're bounderies.
Ex. 06-08-2009 and 06-12-2009 (a week) and sum all the amounts returned by the query.

Anybody has any idea of how I can do this?

thanks a lot

Four Staples
06-12-2009, 06:49 PM
Would be a lot easier if you stored your dates as unix timestamps, then you could < and > to compare them. Then it'd be a simple matter of:SELECT SUM(`field1`) FROM `table1`, `table2` WHERE `date` > startdate AND `date` < enddate

jsbert
06-12-2009, 08:56 PM
Thanks for your help. My system is windows. Is your suggestion doable here, too. Right now I am using the date type. Any suggestions?