ForHosting KIT · Dates & time

Nearest weekday to a date

Type a date and get the closest Monday-to-Friday business day: a Saturday becomes the Friday before, a Sunday the Monday after, and weekdays stay unchanged. Handy for deadlines and payroll cutoffs. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Date
2024-03-16
You get
Result
2024-03-15
Offset days
-1
Base weekday
Saturday
Base weekday iso
6

This nearest-weekday-to-a-date calculator takes a single Gregorian calendar day in strict YYYY-MM-DD form and returns the closest Monday-through-Friday weekday computed as a pure UTC civil date. When the input already falls on Monday through Friday, the result equals that same date with a zero day offset. When the input is a Saturday, the engine steps one day backward to Friday; when it is a Sunday, it steps one day forward to Monday—the unambiguous nearest business day on a seven-day week without holidays. Classic checks include 2024-03-16 (Saturday) mapping to 2024-03-15 (Friday), 2024-03-17 (Sunday) mapping to 2024-03-18 (Monday), and 2024-03-15 (Friday) remaining unchanged.

Where nearest-weekday arithmetic fits in operations, payroll, and software

Operations and product teams need a nearest weekday when a cutoff must land on a business calendar day even if a user entered a weekend stamp, when a settlement or notice date should not sit on Saturday or Sunday, or when a service-level agreement defines delivery as the closest weekday rather than a one-sided next-or-previous rule. Payroll and finance workflows snap free-form event dates into Mon–Fri buckets so batch jobs, ACH windows, and invoice due dates stay off the weekend without inventing a full holiday calendar for every country.

Analysts building cohort labels use the same move to align observation starts away from weekend noise while keeping weekdays exact, avoiding off-by-one errors at year boundaries and leap days. Developers call the contract from scripts to generate deterministic test vectors for schedulers and form validators, to seed demo calendars for onboarding flows, or to satisfy product requirements that demand a pure calendar step without host locale week starts.

Pair it with next-weekday, add-workdays, or weekend-count helpers when you need related calendar steps, and with other free deterministic tools when you are assembling a small lab of date utilities.

Cutoff and settlement snaps

Move weekend-entered cutoffs, settlement stamps, and notice dates to the nearest Monday–Friday day without inventing a one-sided next-business-day policy.

Payroll and batch job alignment

Normalize free-form event dates into Mon–Fri buckets for ACH windows, invoice due dates, and nightly batch calendars that reject Saturday and Sunday.

What does the nearest-weekday-to-a-date calculator cost?

It is free in your browser on this page.

Does this skip public holidays?

No. It only distinguishes Monday–Friday from Saturday–Sunday. Use a holiday-aware business-day tool if you need country calendars.

What date formats are accepted?

Month lengths and leap days are validated; years from 1 to 9999 are supported. UTC civil day only — no timestamps or time zones.

Why does Saturday move to Friday and not to Monday?

Because Friday is one day away and Monday is two. The tool always picks the closest weekday, so a Saturday moves back and a Sunday moves forward.

When is the nearest weekday useful?

Whenever a deadline, a payment or a cutoff lands on a weekend and the rule says to use the closest business day, as with payroll dates or settlement days.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/date/nearest-weekday

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/date/nearest-weekday \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"date":"2024-03-16"}'
{
  "date": "2024-03-16"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "date.nearest_weekday",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Use it free in the browser for scheduling, payroll cutoffs, and SLA alignment, or call the API at $0.002 per successful request when you need reproducible weekday snaps in CI, reporting pipelines, or product features.

What nearest weekday means and what the response contains

Finding the nearest Monday-to-Friday weekday answers a different question from next named weekday, previous weekday, or multi-day business-day offsets: it asks which single civil day is closest to the input while staying inside the Monday through Friday set, treating Saturday and Sunday as non-weekdays that must be reassigned. Distance is measured in whole calendar midnights on the proleptic Gregorian timeline interpreted as a UTC date string with no time-of-day and no local timezone conversion. For any Monday through Friday the offset is zero and result equals the normalized input. If you need a named target weekday on or after a base, holiday-aware business days, or weekend counts between two stamps, use those dedicated tools; this page answers only the nearest Mon–Fri snap for one explicit ISO date. For Saturday the previous Friday is one day away and the following Monday is two days away, so the nearest weekday is Friday with offset_days equal to negative one. For Sunday the following Monday is one day away and the previous Friday is two days away, so the nearest weekday is Monday with offset_days equal to positive one. The calculator returns the normalized base date, the result ISO string, offset_days, boolean flags is_weekend and shifted, the base weekday name and ISO weekday number Monday equals one through Sunday equals seven, the same pair for the result, result year month and day fields, base components for easy piping, and a short formula reminder. Rejected cases include a missing date field, wrong shapes such as 2024/03/16, impossible months, and days that do not exist such as 2023-02-29.

How the date is read and how the result stays reproducible

The string must match four digits, a hyphen, two digits, another hyphen, and two digits; leading or trailing spaces are trimmed, but partial dates, ordinal day-of-year alone, month names, and timestamps with a time component are not expanded here. After parsing, the year must fall between 1 and 9999, the month between 1 and 12, and the day between 1 and the true length of that month in that year, with leap years following the Gregorian rule of divisible by four except century years not divisible by four hundred. The preferred field is date, but aliases iso_date, d, value, base, and from are accepted so spreadsheets, query strings, and typed forms can reuse the same contract without renaming columns. Internally the engine obtains the base day of week with Sakamoto pure-integer arithmetic on a Sunday-zero scale, maps Saturday to a minus-one offset and Sunday to a plus-one offset while leaving Monday through Friday at zero, converts the civil triple to a proleptic Gregorian serial day count using the well-known days_from_civil mapping, adds the integer offset, then recovers year, month, and day with civil_from_days. Pair the free browser run on this page with the priced API when you need the identical nearest weekday inside an automated pipeline that must not drift under host locale settings or daylight-saving transitions.

Where nearest-weekday arithmetic fits in operations, payroll, and software

On this page the work runs entirely in your browser; through the API each successful lookup costs $0.002, failed validation is not charged, and nothing is stored after the response returns. That split — free interactive exploration and a priced, identical API — matches the rest of the KIT tier-A catalog and lets you move from a one-off check to a pipeline without changing the mathematical result.

Deterministic test fixtures

Generate reproducible nearest-weekday ISO strings for unit tests, form validators, and CI assertions without depending on Date or the host clock.

How are Saturday and Sunday mapped?

Saturday snaps back one day to Friday (offset_days = -1). Sunday snaps forward one day to Monday (offset_days = +1). Those are the closest Mon–Fri days on a plain seven-day week.

What happens if the input is already a weekday?

The base date is returned unchanged. offset_days is 0, shifted is false, and result equals the normalized input date.

Read the full KIT documentation →