Date calculator
Calculate the days between two dates, or add and subtract days, weeks, months, and years. Choose how to count the endpoints and copy the result with the dates and rules used.
Loading the calculator…
How many days are between two dates?
From June 1 to June 8 is 7 days by the default setting: the start date is excluded and the end date is included. Include both dates to count 8 calendar dates, or exclude both to count the 6 dates strictly between them. The result keeps your settings beside the total.
An end date earlier than the start gives a negative count. Weeks are complete groups of seven days with the remaining days shown separately. This date difference includes Saturdays, Sundays, and holidays. Use the business day calculator for working weekdays.
Add days to a date, or move by months and years
Choose Add or subtract to find a date a set number of days, weeks, months, or years away. For example, 30 days after January 1, 2026 is January 31. A week always moves seven calendar days.
Month and year shifts keep the original day when it exists. January 31 plus one month becomes February 28 in 2026. February 29, 2024 plus one year becomes February 28, 2025. The calculator flags that adjustment. It applies the full shift to the original date once, so January 31 plus two months becomes March 31.
Calendar dates, weekdays, and ISO weeks
The answer includes the weekday, ISO week number, day of year, and leap-year status for the result date. An ISO week starts on Monday. Dates near New Year can belong to a different ISO week-year. January 1, 2021, for example, is in 2020-W53.
These calculations use dates without a time of day. A clock change does not add or remove a calendar day. For the local time of an appointment in another place, use the time zone converter.
Build a date calculator
Use Date to parse inputs and get a signed calendar-day difference. The browser helper adds endpoint choices, calendar details, and date shifts. Adding or subtracting dates is local arithmetic rather than an API operation.
- Read a start and end date in YYYY-MM-DD. For written numeric dates, ask for mdy or dmy instead of guessing.
- Call Date with to set to the end date. Reject valid=false and missing days. Zero is a valid same-date answer.
- The API returns the signed day difference. Apply endpoint choices locally, then show complete weeks and remaining days. Weekends and holidays count.
- Use the browser helper to add or subtract days, weeks, months, or years. It clamps a missing target-month day to the last day, accepts calendar years 1000-9999, and uses UTC day arithmetic to avoid DST changes.
Installation steps are included in each example. Set PARSEAPI_KEY on your server. Swift and Kotlin use an app key restricted to your app ID.
// npm install @parseapi/sdk@1.14.0
import { parseAPI } from '@parseapi/sdk';
// Set PARSEAPI_KEY on your server.
const parse = parseAPI();
const start = '2026-06-01', end = '2026-06-08';
const includeStart = false, includeEnd = true;
const row = await parse.date(start, { to: end });
if (!row.valid || typeof row.days !== 'number' || !row.to) throw new Error('Date interval unavailable.');
const amount = Math.max(0, Math.abs(row.days) + Number(includeStart) + Number(includeEnd) - 1);
const days = amount ? amount * (row.days < 0 ? -1 : 1) : 0;
console.log({ start: row.date, end: row.to, days, includeStart, includeEnd,
weeks: Math.floor(amount / 7), remainingDays: amount % 7, weekendsAndHolidays: 'included' });
// For ambiguous written input, ask first: parse.date('03/04/2026', { format: 'mdy', to: end }).
// Add/subtract modes use shiftCalendarDate below, not a Date API operation.
Browser date arithmetic
// These pure functions are the same arithmetic used by this browser tool.
// No API operation adds/subtracts dates; call shiftCalendarDate locally.
const DAY_MS = 86400000;
function businessDateDay(value) {
if (!/^\d{4}-\d{2}-\d{2}$/.test(value))
return null;
const [year, month, day] = value.split('-').map(Number);
if (year < 1)
return null;
const date = new Date(0);
date.setUTCFullYear(year, month - 1, day);
if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day)
return null;
return date.getTime() / DAY_MS;
}
function businessDateAfter(value, days) {
const start = businessDateDay(value);
if (start === null || !Number.isInteger(days))
throw new Error('Enter a valid date.');
return new Date((start + days) * DAY_MS).toISOString().slice(0, 10);
}
const DAY = 86_400_000;
function calendarDay(value) {
const day = businessDateDay(value);
if (day === null || Number(value.slice(0, 4)) < 1000)
throw new Error('Enter a valid date between 1000-01-01 and 9999-12-31.');
return day;
}
function isoDay(day) {
if (!Number.isSafeInteger(day) || day < calendarDay('1000-01-01') || day > calendarDay('9999-12-31')) {
throw new Error('The result must be between 1000-01-01 and 9999-12-31.');
}
return new Date(day * DAY).toISOString().slice(0, 10);
}
function countCalendarDays(start, end, includeStart = false, includeEnd = true) {
const difference = calendarDay(end) - calendarDay(start);
const count = Math.max(0, Math.abs(difference) + Number(includeStart) + Number(includeEnd) - 1);
return { start, end, includeStart, includeEnd, days: count ? count * (difference < 0 ? -1 : 1) : 0,
weeks: Math.floor(count / 7), remainingDays: count % 7 };
}
/** Shift the original date once. Clamp a missing target-month day to its last day. */
function shiftCalendarDate(start, amount, unit, operation = 'add') {
const day = calendarDay(start);
if (!Number.isSafeInteger(amount) || amount < 0 || amount > 10_000_000)
throw new Error('Enter a whole number from 0 to 10,000,000.');
if (!['days', 'weeks', 'months', 'years'].includes(unit) || !['add', 'subtract'].includes(operation))
throw new Error('Choose a date operation and unit.');
const offset = amount * (operation === 'subtract' ? -1 : 1);
let result;
let clamped = false;
if (unit === 'days' || unit === 'weeks')
result = isoDay(day + offset * (unit === 'weeks' ? 7 : 1));
else {
const [year, month, date] = start.split('-').map(Number);
const targetMonth = year * 12 + month - 1 + offset * (unit === 'years' ? 12 : 1);
const targetYear = Math.floor(targetMonth / 12);
const monthIndex = ((targetMonth % 12) + 12) % 12;
if (targetYear < 1000 || targetYear > 9999)
throw new Error('The result must be between 1000-01-01 and 9999-12-31.');
const lastDay = new Date(Date.UTC(targetYear, monthIndex + 1, 0)).getUTCDate();
const targetDate = Math.min(date, lastDay);
clamped = targetDate !== date;
result = `${targetYear}-${String(monthIndex + 1).padStart(2, '0')}-${String(targetDate).padStart(2, '0')}`;
}
return { start, amount, unit, operation, date: result, clamped, days: calendarDay(result) - day };
}
function calendarDateDetails(value) {
const day = calendarDay(value);
const date = new Date(day * DAY);
const year = date.getUTCFullYear();
const weekday = date.toLocaleDateString('en-US', { weekday: 'long', timeZone: 'UTC' });
const thursday = new Date((day + 4 - (date.getUTCDay() || 7)) * DAY);
const weekYear = thursday.getUTCFullYear();
const week = Math.ceil(((thursday.getTime() - Date.UTC(weekYear, 0, 1)) / DAY + 1) / 7);
return { weekday, week, weekYear, dayOfYear: day - calendarDay(`${year}-01-01`) + 1,
leapYear: year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0),
daysInMonth: new Date(Date.UTC(year, date.getUTCMonth() + 1, 0)).getUTCDate() };
}
function calendarCountSummary(result) {
return [`${result.days} calendar ${Math.abs(result.days) === 1 ? 'day' : 'days'}`,
`From ${result.start} to ${result.end}.`,
`Start ${result.includeStart ? 'included' : 'excluded'}. End ${result.includeEnd ? 'included' : 'excluded'}. Weekends and holidays included.`,
`${result.weeks} complete ${result.weeks === 1 ? 'week' : 'weeks'} and ${result.remainingDays} remaining ${result.remainingDays === 1 ? 'day' : 'days'}${result.days < 0 ? ', backwards' : ''}.`].join('\n');
}
function calendarShiftSummary(result) {
return [`${result.date} (${calendarDateDetails(result.date).weekday})`,
`${result.operation === 'add' ? 'Add' : 'Subtract'} ${result.amount} ${result.amount === 1 ? result.unit.slice(0, -1) : result.unit} ${result.operation === 'add' ? 'to' : 'from'} ${result.start}.`,
...(result.clamped ? ['The original day does not exist in the target month; the result uses its last day.'] : [])].join('\n');
}
How do I calculate the number of days between two dates?
Enter a start and end date and select Calculate days. By default the start is excluded and the end is included: June 1 to June 8 is 7 days. The result shows the interpreted dates, complete weeks, and remaining days.
Does the date calculator include the start and end dates?
You control each endpoint separately. June 1 through June 8 is 8 days when both count, 7 when exactly one counts, or 6 when neither counts. If both inputs are the same date, it counts once only when both endpoints are included.
Can I add or subtract days, weeks, months, or years?
Yes. Select Add or subtract, enter a whole-number amount and a unit, then calculate the date. One week is seven calendar days. A month or year keeps the original day when it exists. Otherwise the result uses the last day of the target month and flags the adjustment.
What happens when I add a month to January 31 or a year to February 29?
January 31 plus one month becomes February 28 in 2026, or February 29 in 2024. February 29, 2024 plus one year becomes February 28, 2025. The full shift is applied once to the original date: January 31 plus two months becomes March 31, rather than repeating a one-month shift.
Are weekends and holidays included?
Yes. This calculator counts calendar days, including weekends and public holidays. The business day calculator counts Monday through Friday and can also exclude published bank holidays for its supported UK regions.
Why is the day difference negative?
A negative result means the end date is before the start date. Swap dates to reverse the direction. Endpoint options still apply to the dates you entered.
Do daylight-saving clock changes affect the count?
No. These are calendar dates without a time of day, so a 23-hour or 25-hour clock-change day still counts as one date. Use a time zone converter for the local time of an appointment in another place.
What do the ISO week and day-of-year results mean?
ISO weeks begin on Monday. Week 1 contains the first Thursday of the year. The ISO week-year can differ from the date's calendar year near New Year. Day of year counts January 1 as day 1, up to 365 or 366 in a leap year.