1

weekofyear('20121231')返回 1 而weekofyear('20121230')返回 52

Mysql Ver 5,1,47 Cummunity Nt / Windows 7 32 Bit / ODBC 5.1.10 /
First day of Week : Sunday

它应该返回 53 但它返回 1, week('20121231',1),week('20121230')在这两种情况下都返回 53

4

2 回答 2

3

week需要很多参数,weekofyear只是其中一种形式,它与week([date], 3).

阅读手册以查看不同的替代方案。

SQLFiddle

于 2012-12-31T09:35:57.183 回答
0

根据文档weekofyear('20121231')等同week('20121231',1)

WEEKOFYEAR()是一个与 等价的兼容函数 WEEK(date,3)

测试它:

mysql> SELECT weekofyear('20121231'), week('20121231',1), week('20121231',3);
+------------------------+--------------------+--------------------+
| weekofyear('20121231') | week('20121231',1) | week('20121231',3) |
+------------------------+--------------------+--------------------+
|                      1 |                 53 |                  1 |
+------------------------+--------------------+--------------------+
于 2012-12-31T09:37:12.477 回答