{
  "category": "Date and time functions",
  "display_name": "WEEKDAY",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.WEEKDAY",
  "implementation_state": {
    "answer_bank": {
      "excel_builds": [
        "20430"
      ],
      "larger_numeric": 0,
      "last_bit": 0,
      "matched": 19523,
      "other_mismatch": 0,
      "refused": 0,
      "rows": 19523,
      "unread": 0,
      "worst_ulp": 0
    },
    "detail": "Recorded: 19,523 in the answer bank and 11 workbook cells.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "matches",
    "state_label": "Matches every recorded Excel answer",
    "summary": "Matches all 19,534 recorded answers",
    "workbook_corpus": {
      "cells": 11,
      "matched": 11
    }
  },
  "implementations": [
    {
      "commit": "9e1884369a678158dd82d3d74188daf986995e87",
      "flavour": "excel-compatibility-candidate",
      "language": "Rust",
      "name": "CalcFunc",
      "own_code": [
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/dates.rs#L305-L309"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "catalogue/dates::environment",
        "catalogue/dates::system",
        "catalogue/dates::to_1900",
        "catalogue/dates::date_arg",
        "catalogue/dates::strict_num",
        "catalogue/dates::return_type",
        "ported/date_kernels::whole_serial",
        "ported/date_kernels::whole",
        "ported/date_kernels::weekday_sunday_one_based",
        "ported/date_kernels::remap_weekday",
        "ported/date_kernels::weekday_of",
        "ported/date_kernels::weekday",
        "ported/text_kernels::text",
        "ported/text_kernels::text_from_str",
        "ported/text_kernels::date_integer_floor",
        "ported/text_kernels::push_singleton_or_original",
        "ported/text_kernels::push_upper",
        "ported/text_kernels::upper"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/dates.rs#L305-L309",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 19,534 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.WEEKDAY.json",
  "name": "WEEKDAY",
  "notes": [],
  "schema": "efh.function-reference/v1",
  "section_order": [
    "what-it-does",
    "try-it",
    "quirks",
    "how-to-implement",
    "version-differences",
    "alternatives"
  ],
  "sections": {
    "alternatives": "\n### Relationships\n\n\n- **[WEEKNUM](FUNC.WEEKNUM.md)** — the week-of-year counterpart, with its own and differently\n  organized `return_type` table (1, 2, 11–17, 21). The two tables look similar and mean different\n  things; the `return_type` values are *not* interchangeable between the functions.\n- **[ISOWEEKNUM](FUNC.ISOWEEKNUM.md)** — ISO 8601 week numbering, equivalent to `WEEKNUM(s, 21)`\n  on the documented reading.\n- **[NETWORKDAYS](FUNC.NETWORKDAYS.md) and [WORKDAY](FUNC.WORKDAY.md)** — the functions that\n  consume the same weekday notion implicitly, with Saturday and Sunday hard-wired as the weekend;\n  their `.INTL` variants make the weekend definition explicit instead.\n- **[DAY](FUNC.DAY.md)** — day *of month*, the routine confusion.\n- **The `TEXT` function** with a `\"ddd\"`/`\"dddd\"` format code returns the weekday's *name*, and is\n  locale-dependent where `WEEKDAY` is not.\n\n\n",
    "how-to-implement": "\n### Notes for implementers\n\n\n1. **Implement one rotation, not ten branches.** Compute a canonical weekday index from the serial\n   (for example Monday = 0), then map through a small table of (origin, base) pairs keyed by\n   `return_type`. Ten independent branches is ten chances to mis-key a row.\n2. **Validate `return_type` against the exact documented set** — {1, 2, 3, 11, 12, 13, 14, 15, 16,\n   17}. It is not a range: 4 through 10 are invalid, and so is 18.\n3. **Derive the weekday from the serial, not from a calendar library.** This is the function where\n   the leap-year artefact must survive rather than be corrected; a real calendar consulted for\n   \"what weekday was 15 January 1900\" gives the true answer, which is the answer Excel's own\n   documentation says Excel does not give.\n4. **Beware `MOD` with negative operands** if the canonical index is computed by modular\n   arithmetic; the serial range is guarded, but intermediate offsets need not be.\n\n\n",
    "quirks": "\n### Result and edge cases\n\n\nReturns a `Number` in 1…7, or 0…6 for `return_type` 3.\n\n- **Fractional serials** are floored; time of day is irrelevant.\n- **Serials below 61** are in the region Microsoft's own article says returns incorrect values.\n- **Serial 60** — the phantom day itself. There is no true weekday for a day that did not exist,\n  so whatever Excel returns here is a convention, not a fact.\n- **A 1904-system workbook** has no phase problem at all, because 1904 was genuinely a leap year;\n  the same calendar day also has a different serial, so a formula that hard-codes serials and a\n  formula that uses `DATE` behave differently across the two systems.\n\n\n\n### Errors\n\n\nAs documented on the Microsoft page:\n\n- `#NUM!` when `serial_number` is out of range for the current date-base value.\n- `#NUM!` when `return_type` is outside the range in the table above.\n\n`#VALUE!` from an argument that will not coerce to a number, and propagation of an error argument,\nare the ordinary behaviours from\n[coercion and lifting](../model/02-coercion-and-lifting.md), not `WEEKDAY`-specific rules.\n\n\n",
    "sources": "\n- Microsoft 365 support, **WEEKDAY function** —\n  <https://support.microsoft.com/en-us/office/weekday-function-60e44483-2ed1-439f-8bd0-e404c190949a>.\n  Source of the complete `return_type` table and both `#NUM!` conditions.\n- Microsoft Learn, **Excel incorrectly assumes that the year 1900 is a leap year** —\n  <https://learn.microsoft.com/en-us/office/troubleshoot/excel/wrongly-assumes-1900-is-leap-year>.\n  Source of the statement that `WEEKDAY` returns incorrect values for dates before 1 March 1900.\n- [FUNC.DATE](FUNC.DATE.md) — the serial model and the 1900/1904 systems.\n- Handbook call-model chapter [02 coercion and lifting](../model/02-coercion-and-lifting.md).\n- `data/functions/FUNC.WEEKDAY.json`, `data/presence/FUNC.WEEKDAY.json`,\n  `data/battery/FUNC.WEEKDAY.json`.\n\n",
    "version-differences": "The recorded environments below distinguish a reading from a same-input comparison. Counts describe captured inputs in each environment; overlapping captures and comparisons are not totals of unique worksheet calls.\n\n| Excel 16.0 build | Platform and CPU | Captured inputs |\n|---|---|---:|\n| 20430 | Windows, 64-bit, CPU not recorded | 19,523 |\n\nThe record contains no same-input comparison between these environments. Reading different inputs on different builds does not establish either a version change or cross-build agreement.\n\n[Recorded environments and comparison details](https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.WEEKDAY.json).",
    "what-it-does": "\n`WEEKDAY` returns which day of the week a date falls on, as a number. The mapping from serial to\nweekday is fixed by the serial line; what `return_type` selects is only the *numbering* — which\nday counts as 1, and whether the range starts at 0 or 1.\n\nUnderneath the ten documented conventions there is one function and two knobs: an origin day and a\nzero-or-one base. Everything in the table below is that single rotation.\n\n| `return_type` | Numbers returned |\n|---|---|\n| 1 or omitted | 1 (Sunday) through 7 (Saturday) |\n| 2 | 1 (Monday) through 7 (Sunday) |\n| 3 | **0 (Monday) through 6 (Sunday)** |\n| 11 | 1 (Monday) through 7 (Sunday) |\n| 12 | 1 (Tuesday) through 7 (Monday) |\n| 13 | 1 (Wednesday) through 7 (Tuesday) |\n| 14 | 1 (Thursday) through 7 (Wednesday) |\n| 15 | 1 (Friday) through 7 (Thursday) |\n| 16 | 1 (Saturday) through 7 (Friday) |\n| 17 | 1 (Sunday) through 7 (Saturday) |\n\nThree features of that table are worth pointing at, because they are the source of most `WEEKDAY`\nbugs:\n\n1. **`return_type` 3 is the only zero-based option.** Formulas that switch between 2 and 3 without\n   adjusting are off by one everywhere.\n2. **2 and 11 are duplicates**, and **1 and 17 are duplicates**. The 11–17 block is the later,\n   regular family (start day = `return_type` − 10, counting Monday as 1); 1, 2 and 3 are the\n   legacy options that predate it.\n3. **There is no `return_type` for ISO week semantics.** `WEEKDAY(s, 2)` is the ISO-compatible\n   day numbering (Monday = 1), but week *numbering* is a separate function — see\n   [ISOWEEKNUM](FUNC.ISOWEEKNUM.md).\n\n### The 1900 artefact, in Microsoft's own words\n\nWeekday is where Excel's phantom 29 February 1900 becomes an observable wrong answer rather than a\nharmless coordinate shift. Because serial 60 occupies a slot that no real day occupies, every\nserial from 1 to 59 sits one position out of phase with the true weekday of the day it names.\nMicrosoft's leap-year article states this plainly as the one residual problem of not fixing the\nbug: `WEEKDAY` \"returns incorrect values for dates before March 1, 1900\". Dates from 1 March 1900\nonwards are unaffected.\n\nThis is not a defect this Handbook is alleging; it is documented by the vendor. What has *not* been\nchecked here is exactly where the phase break falls in a running Excel — see below.\n\n\n\n### Arguments\n\n\n`WEEKDAY(serial_number, [return_type])` — one required argument and one optional.\n\n**serial_number** — \"a sequential number that represents the date of the day you are trying to\nfind\". Microsoft's page repeats the category advice to use `DATE` rather than text, since text\ndates may be interpreted differently.\n\n**return_type** — optional; the numbering convention, per the table above. Omitted means 1 (Sunday\n= 1). Values outside the documented set are an error, not a silent default.\n\nThe commonly misunderstood position is `return_type` itself: readers assume the number names the\n*first day of the week* directly, which is true for 11–17 (offset by 10) and false for 1, 2 and 3.\n\n\n"
  },
  "signature": {
    "display": "WEEKDAY(serial_number, [return_type])",
    "parameters": [
      {
        "description": null,
        "name": "serial_number",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "return_type",
        "optional": true,
        "repeats": false
      }
    ],
    "trailing_repeats": false
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "implemented",
        "reason": null
      },
      "arity": {
        "max": 2,
        "min": 1
      },
      "category": "Date and time functions",
      "classification": {
        "arg_preparation_profile": "ValuesOnlyPreAdapter",
        "coercion_lift_profile": "Custom",
        "determinism_class": "Deterministic",
        "error_collapse_profile": "None",
        "fec_dependency_profile": "None",
        "host_interaction_class": "None",
        "kernel_signature_class": "Custom",
        "rich_value_usage": "RichBlind",
        "surface_fec_dependency_profile": "RefOnly",
        "thread_safety_class": "SafePure",
        "volatility_class": "NonVolatile"
      },
      "descriptions": {
        "long": null,
        "short": "Day of the week of a date, as a number",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Converts a serial number to a day of the week",
        "microsoft_url": "https://support.microsoft.com/en-us/office/weekday-function-60e44483-2ed1-439f-8bd0-e404c190949a"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "WEEKDAY"
        },
        {
          "locale": "bg-BG",
          "name": "WEEKDAY"
        },
        {
          "locale": "cs-CZ",
          "name": "DENTÝDNE"
        },
        {
          "locale": "da-DK",
          "name": "UGEDAG"
        },
        {
          "locale": "de-DE",
          "name": "WEEKDAY"
        },
        {
          "locale": "el-GR",
          "name": "WEEKDAY"
        },
        {
          "locale": "en-AU",
          "name": "WEEKDAY"
        },
        {
          "locale": "en-GB",
          "name": "WEEKDAY"
        },
        {
          "locale": "en-US",
          "name": "WEEKDAY"
        },
        {
          "locale": "es-ES",
          "name": "DIASEM"
        },
        {
          "locale": "et-EE",
          "name": "WEEKDAY"
        },
        {
          "locale": "fi-FI",
          "name": "WEEKDAY"
        },
        {
          "locale": "fr-FR",
          "name": "JOURSEM*"
        },
        {
          "locale": "he-IL",
          "name": "WEEKDAY"
        },
        {
          "locale": "hr-HR",
          "name": "WEEKDAY"
        },
        {
          "locale": "hu-HU",
          "name": "HÉT.NAPJA"
        },
        {
          "locale": "id-ID",
          "name": "WEEKDAY"
        },
        {
          "locale": "it-IT",
          "name": "WEEKDAY"
        },
        {
          "locale": "ja-JP",
          "name": "WEEKDAY"
        },
        {
          "locale": "ko-KR",
          "name": "WEEKDAY"
        },
        {
          "locale": "lt-LT",
          "name": "WEEKDAY"
        },
        {
          "locale": "lv-LV",
          "name": "WEEKDAY"
        },
        {
          "locale": "nb-NO",
          "name": "HVERDAG"
        },
        {
          "locale": "nl-NL",
          "name": "WEEKDAG"
        },
        {
          "locale": "pl-PL",
          "name": "DZIEŃ.TYG"
        },
        {
          "locale": "pt-BR",
          "name": "WEEKDAY"
        },
        {
          "locale": "pt-PT",
          "name": "DIA.SEMANA"
        },
        {
          "locale": "ro-RO",
          "name": "WEEKDAY"
        },
        {
          "locale": "ru-RU",
          "name": "ДЕНЬНЕД"
        },
        {
          "locale": "sk-SK",
          "name": "WEEKDAY"
        },
        {
          "locale": "sl-SI",
          "name": "WEEKDAY"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "WEEKDAY"
        },
        {
          "locale": "sv-SE",
          "name": "VECKODAG"
        },
        {
          "locale": "th-TH",
          "name": "WEEKDAY"
        },
        {
          "locale": "tr-TR",
          "name": "HAFTANINGÜNÜ"
        },
        {
          "locale": "uk-UA",
          "name": "WEEKDAY"
        },
        {
          "locale": "vi-VN",
          "name": "WEEKDAY"
        },
        {
          "locale": "zh-CN",
          "name": "WEEKDAY"
        },
        {
          "locale": "zh-HK",
          "name": "WEEKDAY"
        },
        {
          "locale": "zh-TW",
          "name": "WEEKDAY"
        }
      ],
      "signature": {
        "display": "WEEKDAY(serial_number, [return_type])",
        "parameters": [
          {
            "description": null,
            "name": "serial_number",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "return_type",
            "optional": true,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "WEEKDAY",
      "version_marker": null,
      "xlcall": {
        "code": "70",
        "symbol": "xlfWeekday"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/weekday-function-60e44483-2ed1-439f-8bd0-e404c190949a"
  },
  "try_it": {
    "formula": "=WEEKDAY(59)"
  },
  "url": "https://handbook.dnacalc.com/functions/WEEKDAY.html",
  "variants": [],
  "versions": [
    {
      "behaviour": "19,523 captured inputs are indexed for this environment. Capture dates: 2026-09-29 to 2026-09-29. This is a reading count, not a comparison with another build.",
      "excel_build": "16.0 build 20430",
      "platform": "Windows, 64-bit, CPU not recorded",
      "sources": [
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/5dc75391aa5125ccc5abdb095da85950980d6fd8/content/evidence/environments/FUNC.WEEKDAY.json"
      ]
    }
  ]
}