我在mysql date_format()的文档中看到,它要么返回53个不同的值,要么返回54个不同的值。据我所知,这些年有52周或53周。这额外的一周从哪里来的?
%U Week where Sunday is the first day of the week (00 to 53)
%u Week where Monday is the first day of the week (00 to 53)
%V Week where Sunday is the first day of the week (01 to 53). Used with %X
%v Week where Monday is the first day of the week (01 to 53). Used with %Xhttps://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html
U旗和V旗有什么区别?U旗不应该有一个范围(00到52)吗?
谢谢!
发布于 2018-07-03 12:41:39
从您在处理2018-01-01 (星期一)- 2018-01-07 (星期日)范围内的日期时可以看到:
Vs可以返回前一年的周号:SELECT DATE_FORMAT("2018-01-05", "%V");
返回53 (本周从周日开始,也就是2017年)。%v的工作原理是一样的,但对于以上数据,它将返回0,因为星期一是一周的第一天,而且已经是2018年了。
U没有这个属性:因为上面的%U将返回1。https://stackoverflow.com/questions/51154334
复制相似问题