Reference · Dates

date.weekday

signature
date.weekday(str) -> int

What it does

The day of the week of a date, as an int: 1 for Monday to 7 for Sunday (ISO 8601). A date-time gives the weekday of its date as written. For the name, use date.format with dddd or ddd.

Examples

print(date.weekday("2026-10-27"), date.weekday("2026-10-26"), date.weekday("2026-11-01"))print(date.format("2026-10-27", "dddd"))
output
2 1 7Tuesday

Edge cases

print(["2026-10-30", "2026-10-31", "2026-11-01"] | map((d) => date.weekday(d) >= 6))print(date.weekday("2026-10-27T23:00:00-05:00"))print(date.weekday("1970-01-01"), date.weekday("0001-01-01"))
output
[false, true, true]24 1

Errors

Text that is not a date or a date-time, or any other value, is a runtime error, not an error value.

this one fails
print(date.weekday("today"))
output
line 1: `date.weekday` expects a date or a date-time as argument 1, got "today"

Chaining

let names = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]print("2026-10-27" | date.weekday | (n) => names[n - 1])print(range(0, 7) | map((i) => date.add_days("2026-10-26", i)) | filter((d) => date.weekday(d) < 6) | len)
output
Tue5

See also

date.parts, date.format, date.add_days, date.days_between

Thread
7Useful? Like it, or add to its thread below.

Thread 0 posts

On date.weekday(): 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