java
sql
html
php
css
xml
ajax
python
mysql
regex
objective-c
silverlight
perl
algorithm
facebook
tsql
php5
asp
postgresql
dom
Do NOT use YEAR(date) - this will calculate YEAR(date) for all dates, even for those, you never use. It will also make use of an index impossible - worst case on the DB layer.
YEAR(date)
Use
$sql="SELECT * FROM table WHERE `date` BETWEEN '$year-01-01' AND '$year-12-31'"
As a general rule: If you have the choice between a calculation on a constant and a calculation on a field, use the former.
Check out the YEAR() docs function for MySQL
YEAR()
SELECT * FROM table WHERE YEAR(date)=2012
select * from table where DATEPART(YEAR,[DATE])=2012