Why can two one-month spans contain different counts of days?

timediff expresses the calendar shift from its second timestamp to its first. A month can span different day counts depending on the start.

SQLite example and interpretation

Mid-February to mid-March and mid-March to mid-April are both a calendar month in 2023. Compute server billing seconds on a fixed-unit timeline.

SELECT timediff('2023-03-15','2023-02-15'),timediff('2023-04-15','2023-03-15');

Result [["+0000-01-00 00:00:00.000", "+0000-01-00 00:00:00.000"]]

中文

为什么同为一个自然月的间隔有不同的天数?

timediff 给出从第二个时刻移至第一个时刻的日历位移,月长会随起点变化。

SQLite 示例与适用条件

2023 年 2 月中到 3 月中以及 3 月中到 4 月中都是一月。计算服务器计费秒数应在固定时间单位下相减。

SELECT timediff('2023-03-15','2023-02-15'),timediff('2023-04-15','2023-03-15');

结果 [["+0000-01-00 00:00:00.000", "+0000-01-00 00:00:00.000"]]

References / 参考来源

Keep reading / 继续阅读