You also might be able to 

 

Select date_format(date_time ,'%Y") as year from hits where year = 2006;

 

 

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Michael Roush
Sent: Tuesday, April 24, 2007 6:10 AM
To: [email protected]
Subject: Re: [php_mysql] Date/Time Column, accessing only year

 

--- Jer <[EMAIL PROTECTED] <mailto:whoisquilty%40gmail.com> > wrote:

> I'm trying to generate a table that gives some
> statistics. I've got a date time column that 
> registers hits. I need to calculate the number of
> hits for 2006 using the 'date' column, which 
> is the date time column.
> 
> How do I access only the year?

What format is the data in? Is it like "2006-07-04"? 
If so, you can use a query something along the order
of SELECT * FROM hits WHERE date LIKE "2006-%" or
something like that?

If the data is stored as UNIX timestamps, then you can
use mktime() functions to find out the timestamps for
11:59pm 12/31/2005 and 12:00am 1/1/2007 and query for
everything between them.


Michael Roush
[EMAIL PROTECTED] <mailto:mdroush%40yahoo.com> 

"The power of the Web is in its universality. Access by everyone
regardless of disability is an essential aspect." 
-- Tim Berners-Lee, W3C Director and inventor of the World Wide Web

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com <http://mail.yahoo.com>  

 



[Non-text portions of this message have been removed]

Reply via email to