ForHosting KIT · Dates & time

First and last day of month

Pick a year and a month to get its first and last dates: February 2024 runs from 2024-02-01 to 2024-02-29, while February 2023 ends on 2023-02-28. Ready for invoices and report ranges. 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
Year
2,024
Month
2
You get
Month name
February
First day
1
Last day
29
Days in month
29

This first-and-last-day-of-month calculator takes a Gregorian calendar year and a month number from one through twelve and returns the opening and closing calendar dates of that month in strict YYYY-MM-DD form. Classic checks include February 2024 yielding first date 2024-02-01 and last date 2024-02-29 with twenty-nine days, February 2023 yielding 2023-02-28 as the last day, and April 2024 yielding 2024-04-01 through 2024-04-30. The engine uses only deterministic table-driven month lengths with the Gregorian leap-year rule, so it never consults the host clock, never samples randomness, and never calls the network.

Where month bounds fit in billing, reporting, and software

Operations and finance teams need month start and end dates when a subscription invoice covers a full calendar month, when a retention policy is stated as the month containing an event, or when a dashboard filter defaults to the current reporting month without hard-coding thirty or thirty-one. Analysts building cohorts use the same bounds to label observation windows that open on the first and close on the true last day, avoiding silent truncation when February or short months appear in multi-year backfills.

Educators and standards writers use the tool to demonstrate leap-day month ends such as February 2024 versus February 2023 without relying on opaque calculator apps that silently include times of day. Pair it with days-between, subtract-days, or ISO week helpers when you need related calendar steps, and with other free deterministic tools when you are assembling a small lab of date utilities.

Billing and invoice ranges

Obtain inclusive first and last calendar dates for a year-month so invoices and subscriptions cover the full month without hard-coding day counts.

Leap February and short months

Verify that February ends on the 28th or 29th by Gregorian leap rules, and that April, June, September, and November correctly close on the 30th.

What does the first-and-last-day-of-month calculator cost?

It is free in your browser on this page.

What happens if month is outside 1 to 12?

Month must be an integer from 1 (January) through 12 (December).

How are leap years handled for February?

A year is a leap year if it is divisible by 4, except century years that are not divisible by 400. February then has 29 days (for example 2024 and 2000), otherwise 28.

Which months end on the 30th?

April, June, September and November close on the 30th; April 2024, for example, runs from 2024-04-01 to 2024-04-30. February ends on the 28th, or the 29th in leap years, and the other months end on the 31st.

Are both dates included in the month range?

Yes. The first date is always day 1 and the last date is the true final day, so a filter or an invoice running from one to the other covers the whole month with no day lost at the end.

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/month-start-end

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/month-start-end \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"year":2024,"month":2}'
{
  "year": 2024,
  "month": 2
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "date.month_start_end",
  "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.

year_min1
year_max9999
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 billing windows, report ranges, and homework, or call the API at $0.002 per successful request when you need reproducible month bounds in CI, scheduling pipelines, or product features that must not invent end-of-month dates by hand.

What month start and end mean and what the response contains

Knowing the first and last calendar day of a month answers a different question from counting days between two arbitrary dates, finding the next weekday, or converting Julian day numbers: it fixes the civil bounds of a named year-month so that report ranges, invoices, and retention windows open on day one and close on the true last day without off-by-one errors at thirty-day months or leap Februaries. If you need whole-day distance between two free dates, weekday navigation, or ISO week conversion, use those dedicated tools; this page answers only the calendar start and end of a single validated year-month. You supply an integer year and an integer month from one for January through twelve for December; the calculator validates those fields, looks up how many days that month has in that year under the proleptic Gregorian calendar, and returns first_date as YYYY-MM-01, last_date as YYYY-MM with the true last day zero-padded, first_day always equal to one, last_day equal to days_in_month, the month_name in English for display, is_leap_year for February-sensitive callers, and a short formula reminder. Rejected cases include a missing year or month, non-integer values, years outside one through 9999, and any month outside one through twelve such as zero, thirteen, or negative indices.

How year and month are read and how leap Februaries stay correct

Each value may arrive as a number, a pure integer string with an optional sign, or a bigint that fits the safe integer range; embedded decimals, hex prefixes, and non-numeric tokens are rejected with a clear message so a bad cell does not become a wrong last day. The preferred first field is year, but aliases y and Y are accepted so spreadsheets, query strings, and typed forms can reuse the same contract without renaming columns. The preferred second field is month, with aliases m, M, and mon for the same reason. After parsing, year must fall between 1 and 9999 inclusive, and month must fall between 1 and 12 inclusive — values such as 0, 13, or 2024 as a month fail with invalid_input naming the month field. Month lengths come from a fixed table of thirty-one, thirty, or twenty-eight days, except February which becomes twenty-nine when the year is a Gregorian leap year: divisible by four, except century years that are not divisible by four hundred. That rule correctly gives 2024-02-29 and 2000-02-29 while rejecting any attempt to invent thirty-two days in any month. First day is always one; last day equals days_in_month; both bounds are formatted with four-digit years and two-digit months and days. Pair the free browser run on this page with the priced API when you need the identical month bounds inside an automated pipeline.

Where month bounds fit in billing, reporting, 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 first_date and last_date strings for unit tests, property checks, and CI assertions without depending on Date or the host clock.

How are the first and last dates defined?

For a validated year and month, first_date is always YYYY-MM-01 and last_date is YYYY-MM-{days_in_month}, where days_in_month comes from the Gregorian month-length table (February 29 in leap years).

Does this tool use the host Date object?

No. Month lengths and leap rules are pure integer arithmetic with a fixed table, so results are reproducible across runtimes without timezone or clock effects.

Read the full KIT documentation →