mysql:date_format将2016年的第一周转换为上周
问题描述:
2016年的第一周,实际上是2015年的第53周,由mysql转换为2016年第53周。 我如何将它转换为实际的一周,即2015年的第53周? http://www.epochconverter.com/weeks/2016mysql:date_format将2016年的第一周转换为上周
select date_format('2016-01-03 09:16:18','%y-%v');
16-53
答
使用
select yearweek('2016-01-03',1);
的第二个参数是weekmode,值1是指周的星期一开始。
或者
SELECT date_format('2016-01-03 09:16:18', '%x-%v')
的%x表示星期周一
开始参考这里:http://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html