Looking backward from a date

Many deadlines are written as a number of days before something: a notice due 30 days before a lease ends, a refund request filed no later than 14 days before an event, a payment reminder sent 10 days before the due date. This page does that subtraction. Enter the anchor date and the number of days, and it returns the earlier date in YYYY-MM-DD form. It counts calendar days, with no regard for weekdays, holidays or the time of day. If your rule counts only business days, this page gives the calendar date and you will need to adjust for working days separately.

How the date is computed

The page turns the start date into an ordinal number, which is a running day count in the Gregorian calendar. It subtracts the days you entered and converts the new ordinal back to year, month and day. The formula is result = fromOrdinal(ordinal(date) - days). Because the work is done on whole days, no clock time enters the calculation, and daylight-saving changes cannot add or remove an hour. Months of different length and the extra day in leap years are handled by the conversion, so you do not need to count them by hand. The days input is a whole number from 0 to 3,652,058.

The default: two days before March 1, 2024

The page begins with 2024-03-01 and 2 days. One day before March 1, 2024 is February 29, because 2024 is a leap year, and two days before is February 28. The page returns 2024-02-28. Running the same subtraction from 2023-03-01 gives 2023-02-27, since February 2023 has only 28 days. The two cases show why you should not shortcut month ends by memory. Another quick test: subtracting 1 day from 2024-01-01 returns 2023-12-31, which crosses a year boundary, and the page handles that the same way as any other date. Subtracting 0 days returns the starting date unchanged, which is a quick way to confirm that you entered the date you meant to. Large day counts also work: 1,000 days before 2024-03-01 is 2021-06-05, which is about two years and nine months earlier. For very long spans, watch that the result stays in the supported years, and prefer a month or year based page when the rule is stated that way.

A hundred days before a deadline

Imagine a project milestone on 2024-12-25 and a requirement to submit a document 100 days before it. The date works out to 2024-09-16. A way to confirm the answer is to count forward: September 16 to September 30 is 14 days, October adds 31, November adds 30, and December 1 through 25 adds 25, for a total of 100. In a leap year the day-of-year numbers shift by one after February, so a count that uses a non-leap table would land a day off. Letting the page handle the calendar avoids that slip, which is common in hand calculations that cross late February or early March.

Subtracting a year's worth of days

Subtracting 365 days does not always give the same calendar date one year earlier. From 2024-03-01, which comes after a leap day, subtracting 365 days returns 2023-03-02, because the previous 366 days span a full leap year. From 2023-03-01 subtracting 365 days returns 2022-03-01. If you want the same date one year earlier, use a years or months based page instead. The day-count approach is appropriate when the rule really is a number of days, such as a 90-day return window, a 30-day notice period or a 180-day statute of limitations in a policy you have confirmed elsewhere.

Counting convention and the start day

Whether a deadline "30 days before March 31" includes the end date is a question of wording, not arithmetic. The page treats the input date as day zero. Subtracting 30 days from 2024-03-31 gives 2024-03-01, which is exactly 30 calendar days earlier, so it counts the start date as day zero and not as day one. Some agreements count the first day as day one, which would move the result by a day. If a legal or contractual rule is involved, read how the document counts days and adjust by one if needed. The page cannot tell which convention a clause intends.

Subtracting weeks and chaining steps

A rule given in weeks is just a multiple of seven days. Fourteen days before 2024-03-01 is 2024-02-16, and four weeks before the same date is 2024-02-02, since 28 days back from March 1 in a leap year lands there. Chains of notices work the same way: if a supplier needs 21 days to ship and you need the parts 10 days before a launch on 2024-09-30, subtract 31 days in total to get 2024-08-30. Doing the sum in one step avoids the error of subtracting from an already rounded date. When several deadlines depend on one another, write each date and its day offset in a short list, so that moving the launch date means changing one input and rerunning the page.

Weekdays and holidays

The date that comes back might land on a Saturday, Sunday or public holiday, and the page does not shift it. Some rules move a deadline that falls on a non-business day to the next business day, others to the previous one, and others leave it unchanged. Which rule applies depends on the document or the jurisdiction. Run the calendar subtraction first, check the weekday on a calendar, then apply the shifting rule yourself. Keeping those two steps separate makes it easy to explain how you reached the final date to a colleague or a counterparty. A subtraction of a multiple of seven days always keeps the same weekday, which is a simple consistency check: 28 days before a Friday is a Friday.

Range limits and checks

The starting date must be a valid Gregorian date from 0001-01-01 to 9999-12-31, and the result must stay inside that range. The upper limit of 3,652,058 days is the number of days between the first and last supported dates. A day count of 0 returns the same date. Fractions and negative numbers are not accepted. To go forward instead of backward, use a page that adds days. When you record a result, keep the starting date and the number of days next to the answer, so that the subtraction can be repeated and checked.