Formatting Data

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

RobbieL
Forum Commoner
Posts: 31
Joined: Fri Mar 23, 2007 5:57 pm

Post by RobbieL »

Both suggestions worked great. Is there a good reason for using one over the other?

For my SQL query to pull all the data by year only, I've looked through the MySQL manual and spotted the YEAR function. It doesn't give an example of it in a query, but am I right in assuming it works similiar to other functions like SUM?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

YEAR returns the year part of the date. Try running a query in your favorite query browser to see how it works.
RobbieL
Forum Commoner
Posts: 31
Joined: Fri Mar 23, 2007 5:57 pm

Post by RobbieL »

Woot! Got it all working!

Big thanks to you guys! Can't tell you how much I appreciate all your help. Wish I could return the favour, but I think it's going to be a while before I'm at that level.

Big thanks again. :wink:
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

No problem. Don't worry about paying it back - pay it forward ;)
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

And congrats on getting it worked out.
Post Reply