ISO weekday numbering is the ISO 8601 convention of numbering weekdays 1 through 7, with Monday = 1 and Sunday = 7. This matches the ISO rule that the week starts on Monday.
Contrast with Excel
Microsoft Excel's WEEKDAY function defaults to a different convention. By default, Sunday = 1 and Saturday = 7. Passing the optional argument 2 switches to the ISO convention (Monday = 1, Sunday = 7). Passing 3 returns Monday = 0 through Sunday = 6. Spreadsheet formulas that mix conventions are a common source of off-by-one errors in scheduling.
Programming language conventions
Three common languages each use a different default:
- Python —
datetime.weekday()returns Monday = 0 through Sunday = 6. The separatedatetime.isoweekday()returns Monday = 1 through Sunday = 7. - JavaScript —
Date.prototype.getDay()returns Sunday = 0 through Saturday = 6. - PostgreSQL —
EXTRACT(DOW FROM date)returns Sunday = 0;EXTRACT(ISODOW FROM date)returns Monday = 1.
Always check the language reference before writing weekday logic. A mismatch between systems can shift schedules, payroll cycles, or calendar week calculations by a full day.