...

View Full Version : Change Month from digit to name



1andyw
04-28-2009, 06:57 PM
Hi,

This query returns the year as 2009 and the month as 04. How can I have the month displayed as Apr?


$sql = "SELECT
DISTINCT `volrecords`.`id`,
EXTRACT(YEAR FROM date) AS Year,
EXTRACT(MONTH FROM date) AS Month, firstname,lastname,SUM(hours) AS HoursWorked,areaofinterest
FROM volrecords, hoursworked
WHERE `volrecords`.`id` = `hoursworked`.`vol_id`
AND EXTRACT(MONTH FROM date)='$month'
AND EXTRACT(YEAR FROM date)='$year'
AND areaofinterest = 'Cafe'
GROUP BY lastname";
if(!$sql){echo "Unable to select" . mysql_error();}
$rs = mysql_query($sql,$conn);
if(!$rs){echo "No query" . mysql_error();}
while($row=mysql_fetch_array($rs)){
echo("<tr><td>"
. $row['lastname'] . ", " . $row['firstname'] . "</td><td>"
. $row['Year'] ."</td><td>"
. $row['Month'] . "</td><td>"
. $row['HoursWorked'] . "</td><td>"
.$row['areaofinterest'] . "</td></tr>");
}


Thanks,

Andy

oesxyl
04-28-2009, 07:37 PM
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_monthname

best regards

1andyw
04-28-2009, 08:17 PM
Thank you.

Andy:)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum