Why can a December date belong to week one of the next year?

SQLite versions supporting ISO week formatting expose the ISO week year with %G and week number with %V. Use them as a pair.

SQLite example and interpretation

December 30, 2024 belongs to ISO week 01 of 2025. Combining its calendar year with that week number mislabels the report.

SELECT strftime('%G-W%V','2024-12-30'),strftime('%Y','2024-12-30');

Result [["2025-W01", "2024"]]

中文

年末日期为什么可能归入下一年的第一周?

支持 ISO 周格式的 SQLite 可用 %G 与 %V 取得 ISO 周所属年份和周号,二者应配套使用。

SQLite 示例与适用条件

2024 年 12 月 30 日属于 2025 年第 01 周。若使用日历年 %Y 拼接周号,会把这条记录放进错误的周报。

SELECT strftime('%G-W%V','2024-12-30'),strftime('%Y','2024-12-30');

结果 [["2025-W01", "2024"]]

References / 参考来源

Keep reading / 继续阅读