{
  "id": "sobriety",
  "version": "7052112e445e",
  "status": "published",
  "name": "Sobriety Calculator",
  "question": "How long is my sobriety?",
  "summary": "Counts the days sober from a sobriety date up to today, also as weeks and as years, months and days, with the next recovery milestone and the money not spent.",
  "category": "days",
  "subcategory": "dates",
  "url": "https://www.acalculator.org/days/sobriety-calculator",
  "markdown": "https://www.acalculator.org/days/sobriety-calculator.md",
  "kind": "function",
  "method": "days sober = count date − sobriety date, in whole calendar days; the next milestone is the first of 30, 60, 90 days, 6, 9 months, 1 year, 18 months, 2, 3, … years after the sobriety date that falls on or after the count date.",
  "assumptions": [
    "Dates are whole calendar days in the Gregorian calendar, with no time of day.",
    "The sobriety date is day 0: the day after it is 1 day sober.",
    "Month and year milestones add calendar months; a day past the end of a month moves to its last day (a February 29 date reaches 1 year on February 28).",
    "The count date is today unless you change it; the page reads today’s date from your device when it loads.",
    "Money not spent is the weekly spend × days ÷ 7, at the same weekly spend throughout."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "start": {
        "title": "Sobriety date",
        "description": "Your first day without alcohol or drugs.",
        "type": "string",
        "format": "date"
      },
      "end": {
        "title": "Count up to",
        "description": "The date to count up to. Today, unless you change it.",
        "type": "string",
        "format": "date"
      },
      "spend": {
        "title": "Money spent per week before (optional)",
        "description": "What you used to spend on alcohol or drugs in a week, to see the money not spent.",
        "type": "number",
        "x-unit": "USD",
        "minimum": 0,
        "maximum": 1000000
      }
    }
  },
  "outputs": {
    "days": {
      "label": "Days sober",
      "description": "Calendar days from the sobriety date up to the count date: the count date minus the sobriety date.",
      "format": "integer"
    },
    "weeks": {
      "label": "In weeks",
      "description": "The days as whole weeks and the days left.",
      "format": "duration"
    },
    "span": {
      "label": "In years, months, and days",
      "description": "The time sober as whole years, then whole months, then days.",
      "format": "duration"
    },
    "next": {
      "label": "Next milestone",
      "description": "The next milestone on or after the count date: 30, 60 or 90 days, 6 or 9 months, 1 year, 18 months, or a whole number of years.",
      "format": "text"
    },
    "nextDate": {
      "label": "Next milestone date",
      "description": "The date of the next milestone.",
      "format": "date"
    },
    "until": {
      "label": "Days to the next milestone",
      "description": "Calendar days from the count date to the next milestone; 0 when it is the count date.",
      "format": "integer"
    },
    "reached": {
      "label": "Last milestone reached",
      "description": "The latest milestone before the count date, when there is one.",
      "format": "text"
    },
    "saved": {
      "label": "Money not spent",
      "description": "The weekly spend × days sober ÷ 7, when a weekly spend is given.",
      "format": "money"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "start": "2026-06-24",
      "end": "2026-10-02"
    },
    "outputs": {
      "days": 100,
      "weeks": {
        "weeks": 14,
        "days": 2
      },
      "span": {
        "years": 0,
        "months": 3,
        "days": 8
      },
      "next": "6 months",
      "nextDate": "2026-12-24",
      "until": 83,
      "reached": "90 days"
    },
    "text": "100 days sober since June 24, 2026."
  },
  "examples": [
    {
      "given": {
        "start": "2026-01-01",
        "end": "2026-09-30",
        "spend": 70
      },
      "expect": {
        "days": 272,
        "weeks": {
          "weeks": 38,
          "days": 6
        },
        "span": {
          "years": 0,
          "months": 8,
          "days": 29
        },
        "next": "9 months",
        "nextDate": "2026-10-01",
        "until": 1,
        "reached": "6 months",
        "saved": 2720
      },
      "source": "Julian Day numbers (Meeus, Astronomical Algorithms, 1991, chapter 7): JD 2461313.5 − JD 2461041.5 = 272; hand calculation in content.mdx; Python: (date(2026,9,30) - date(2026,1,1)).days = 272, 70 × 272 ÷ 7 = 2720"
    },
    {
      "given": {
        "start": "2026-07-02",
        "end": "2026-09-30"
      },
      "expect": {
        "days": 90,
        "next": "90 days",
        "nextDate": "2026-09-30",
        "until": 0,
        "reached": "60 days"
      },
      "source": "Gregorian calendar (ISO 8601): July 2 to July 31 is 29 days, plus 31 in August and 30 in September; hand calculation in content.mdx; Python: date(2026,7,2) + timedelta(90) = date(2026,9,30)"
    },
    {
      "given": {
        "start": "2024-02-29",
        "end": "2026-03-01"
      },
      "expect": {
        "days": 731,
        "span": {
          "years": 2,
          "months": 0,
          "days": 1
        },
        "next": "3 years",
        "nextDate": "2027-02-28",
        "reached": "2 years"
      },
      "source": "Gregorian leap-year rule (ISO 8601): 2024 is a leap year, 2025 and 2026 are not; hand calculation in content.mdx; Python: (date(2026,3,1) - date(2024,2,29)).days = 731"
    },
    {
      "given": {
        "start": "2026-09-30",
        "end": "2026-09-30"
      },
      "expect": {
        "days": 0,
        "next": "30 days",
        "nextDate": "2026-10-30",
        "until": 30
      },
      "source": "hand calculation in content.mdx: the same date is 0 days; Python: date(2026,9,30) + timedelta(30) = date(2026,10,30)"
    }
  ],
  "sources": [
    "NIST Time and Frequency Division, Time and Frequency from A to Z, L (leap year: the Gregorian rule), retrieved 2026-10-01. https://www.nist.gov/pml/time-and-frequency-division/popular-links/time-frequency-z/time-and-frequency-z-l",
    "Meeus J. Astronomical Algorithms, 1991, chapter 7, Julian Day (day counts between calendar dates)."
  ],
  "related": [
    "days-since",
    "days-between-dates",
    "date",
    "weeks"
  ],
  "changelog": []
}
