Reference · Dates
date.start_of_month
signature
date.start_of_month(str) -> strWhat it does
The first day of a date's month, as ISO text: "2026-10-27" gives "2026-10-01". It
takes a date, not a date-time.
Examples
print(date.start_of_month("2026-10-27"), date.start_of_month("2024-02-29"))output
2026-10-01 2024-02-01Edge cases
- The first of a month gives itself.
- Combined with
date.add_monthsit walks months: the start of next month, of last month.
print(date.start_of_month("2026-10-01"))print(date.start_of_month(date.add_months("2026-10-27", 1)), date.start_of_month("2026-01-15") | date.add_months(-1))output
2026-10-012026-11-01 2025-12-01Errors
A date-time, text that is not a date, or any other value is a runtime error, not an error value.
this one fails
print(date.start_of_month("2026-10-27T10:00:00Z"))output
line 1: `date.start_of_month` expects a date (YYYY-MM-DD) as argument 1, got the date-time "2026-10-27T10:00:00Z" (`date.date_in` gives its date)Chaining
print("2026-10-27" | date.start_of_month | date.weekday)print(["2026-10-27", "2026-10-03", "2026-11-14"] | map(date.start_of_month) | unique)output
4["2026-10-01", "2026-11-01"]See also
date.end_of_month, date.add_months, date.days_in_month, date.date_in
Thread
Thread 0 posts
On date.start_of_month(): questions, tips, corrections, and code that uses it.
No posts yet. The first one opens the thread.
Edit this page on GitHub · every example's output was made by running it (tools/refcheck.mjs) · questions on Discord or r/quillo