I have a database table that contains a field titled 'date', entered in the YYYY-MM-DD format.
I want to be able to select from that table ONLY the records entered within the past calendar month, not necessarily the last 30 days.
In other words, as of today (2003/12/05) it would only select records entered from 2003/12/01 to today. I want to run a otal of another column for these results.
I have tried this, but I cannot get it to sperate the month:
<?
$today = getdate();
$month = $today['mon'];
$day = $today['mday'];
$year=$today['year'];
include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);
mysql_select_db ("margaritaair_com");
$query = "SELECT SUM(hours) AS monthtotal FROM flightlog WHERE macid='MAC100' AND date ='$month';
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_assoc($result);
mysql_close();
?>