Snipget.ai

Add or subtract a date interval

Exact
dates_add

Deterministic and authoritative — the canonical answer for this input.

Add (or subtract, with negatives) a calendar interval to a datetime. Calendar-correct: Jan 31 + 1 month → Feb 28/29, not an overflow. Accepts years/months/weeks/days/hours/minutes/seconds. Processing multiple inputs? Use `dates_add_batch` to do up to 1000 in one call.

Parameters

valuestringrequired

ISO 8601 datetime to add an interval to.

yearsintegeroptional
monthsintegeroptional
weeksintegeroptional
daysintegeroptional
hoursintegeroptional
minutesintegeroptional
secondsintegeroptional

Call it

curl -X POST https://api.snipget.ai/v1/dates/add \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{"value":"2024-01-31","months":1}'

The Batch tab sends up to 1000 inputs in one call via /v1/dates/add/batch.

Example response

{
  "input": "2024-01-31",
  "is_valid": true,
  "result": "2024-02-29T00:00:00",
  "applied": {
    "months": 1
  }
}

FAQ

Why not just add the days myself?

Calendar math trips up both people and language models. Adding one month to January 31 should land on the last day of February, not spill into March. This tool does that correctly every time, accounting for short months and leap years.

How do I subtract instead of add?

Use negative numbers. Set days to -30, or months to -1, to go backward. You can mix and match years, months, weeks, days, hours, minutes, and seconds in a single call.

Is the answer reliable?

Yes. This is an exact, deterministic tool, so the same input always returns the same result. It is the authoritative answer, not a guess.

What does it not do?

It does not parse messy date text. The starting value must be a clean ISO date or datetime like 2024-01-31. If you have a messy string like 'Jan 31 2024', run it through the date parse tool first.

What happens if I send a bad date?

You get a clear result with confidence 0 and a why_invalid reason, not a crashing error. Check is_valid in the response before using the result.

Related tools