我在mysqldate_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 %X
https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html
那你和V标志有什么区别呢?U 标志的范围不应该是 (00 到 52(吗?
谢谢!
从您在玩日期时可以看到的 范围 2018-01-01 (星期一( - 2018-01-07 (星期日( 您可以看到:
V
S 可以返回上一年的周数:
SELECT DATE_FORMAT("2018-01-05", "%V");
返回 53(此处的一周从星期日开始,即 2017 年(。%v
的工作方式相同,但对于上述内容将返回 0,因为星期一是一周的第一天,并且已经在 2018 年。
U
s 没有该属性:对于上述带有%U
将返回 1。