SQL语句里怎么获得当前年份(MySQL数据库)

使用函数Year及CurDate的组合: Year(CurDate())

select      date_format(min(date),'%Y-%m-%d') as mindate,
            date_format(max(date),'%Y-%m-%d') as maxdate,
            weekofyear(date) as weekyear,
            format(sum(hours),2) as sumhours 
from 
            daywork 
where 
            userid='myid' 
            and date_format(date,'%Y')=Year(CurDate()) 
group by    weekyear 
order by    weekyear

 

posted @ 2016-07-18 15:12  逆火狂飙  阅读(8860)  评论(0编辑  收藏  举报
生当作人杰 死亦为鬼雄 至今思项羽 不肯过江东