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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM