Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-28-2009, 05:57 PM   PM User | #1
1andyw
Regular Coder

 
Join Date: Jul 2006
Posts: 171
Thanks: 13
Thanked 1 Time in 1 Post
1andyw is an unknown quantity at this point
Change Month from digit to name

Hi,

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

Code:
$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
1andyw is offline   Reply With Quote
Old 04-28-2009, 06:37 PM   PM User | #2
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
http://dev.mysql.com/doc/refman/5.0/...tion_monthname

best regards
oesxyl is offline   Reply With Quote
Old 04-28-2009, 07:17 PM   PM User | #3
1andyw
Regular Coder

 
Join Date: Jul 2006
Posts: 171
Thanks: 13
Thanked 1 Time in 1 Post
1andyw is an unknown quantity at this point
Thank you.

Andy
1andyw is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:28 PM.


Advertisement
Log in to turn off these ads.