Page 1 of 1

The BETWEEN funtion

Posted: Fri Mar 19, 2004 8:54 am
by JayBird
I have this query which add up the ammout spent in petty cash between two dates

Code: Select all

// Date the petty cash system started
$startOfCashDate = "2003-10-01";

// The date of the end of last month
$endoflastmonth = $last_year."-".$last_month."-".$lastday."";

$sql = "SELECT SUM(debit_amount) FROM petty_cash WHERE date_spent BETWEEN '$startOfCashDate' AND '$endoflastmonth'";
From what i can see, BETWEEN returns all the figures between the two dates not including the to date.

How can i get bwetween and including?

Thanks

Mark

Posted: Fri Mar 19, 2004 2:21 pm
by Illusionist
link says that it depends on your database...

Posted: Fri Mar 19, 2004 3:47 pm
by fractalvibes
WHERE date_spent >= '$startOfCashDate'
AND date_spent <= '$endoflastmonth'";

Posted: Fri Mar 19, 2004 3:51 pm
by Illusionist
Ahh! nice one fractalvibes! I didn't even think about that!!