How can you select the first Monday on or after a date?

weekday N advances a date to the requested weekday and keeps a date already on that weekday. Monday has number one.

SQLite example and interpretation

Sunday March third and Monday March fourth both map to the fourth. A strictly future meeting requires a separate rule for Mondays.

SELECT date('2024-03-03','weekday 1'),date('2024-03-04','weekday 1');

Result [["2024-03-04", "2024-03-04"]]

中文

怎样安排本日或之后最近的星期一?

weekday N 将日期推进至指定星期;若原日期已匹配,日期保持不变。星期一编号为 1。

SQLite 示例与适用条件

周日 3 月 3 日和周一 3 月 4 日都映射到 4 日。若业务要求严格的下一次,已是周一的情况要另算。

SELECT date('2024-03-03','weekday 1'),date('2024-03-04','weekday 1');

结果 [["2024-03-04", "2024-03-04"]]

References / 参考来源

Keep reading / 继续阅读