mysql: date_format 将 2016 年的第一周转换为最后一周
mysql: date_format converts the first week of 2016 into the last week
2016年的第一周,实际上是2015年的第53周,通过mysql转换为2016年的第53周。
如何将其转换为真实的一周,即 2015 年的第 53 周?
http://www.epochconverter.com/weeks/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
2016年的第一周,实际上是2015年的第53周,通过mysql转换为2016年的第53周。 如何将其转换为真实的一周,即 2015 年的第 53 周? http://www.epochconverter.com/weeks/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