SELECT DATE_FORMAT(`date`,'%Y-%m') FROM table
this will select field "date" from db under a special format (ex. 2006-01, 2006-02, 2006-03)
if u want to create date range values and u want to know the number of days a month have, then there is a php function that do that for u:
Ex.
$month = date('n');
$year = date('Y');
$num = cal_days_in_month(CAL_GREGORIAN, $month, $year);
For what example u made it should go like this
for ( $month=1; $month<13; $month++) {
/**
* this :str_pad($month,2,'0',STR_PAD_LEFT)
* will put '0' in from on a string if the string is less then 2 caracters long
* ex. is month = 3 then str_pad($month,2,'0',STR_PAD_LEFT) returns 03
**/
$cal[$month]['first_day'] = "2006-".str_pad($month,2,'0',STR_PAD_LEFT)."-01";
$cal[$month]['last_day'] = "2006-".str_pad($month,2,'0',STR_PAD_LEFT)."-".cal_days_in_month(CAL_GREGORIAN, $month, 2006);
}
echo "<pre>",print_r($cal,1),"</pre>";