{"id":23517,"library":"datedelta","title":"datedelta","description":"Provides a DateDelta class for arithmetic between dates, similar to datetime.timedelta but for date objects. Current version 1.4, release cadence is low (last release 2019).","status":"active","version":"1.4","language":"python","source_language":"en","source_url":"https://github.com/aaugustin/datedelta","tags":["date","arithmetic","delta","calendar"],"install":[{"cmd":"pip install datedelta","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"Standard import","symbol":"DateDelta","correct":"from datedelta import DateDelta"},{"note":"Constants for constructing deltas","symbol":"YEARS, MONTHS, WEEKS, DAYS","correct":"from datedelta import YEARS, MONTHS, WEEKS, DAYS"}],"quickstart":{"code":"from datetime import date\nfrom datedelta import DateDelta, DAYS, MONTHS, YEARS\n\ntoday = date.today()\ndelta = DateDelta(years=1, months=2, days=10)\nnew_date = today + delta\nprint(new_date)\n\n# Or using constants:\nnew_date2 = today + 1*YEARS + 2*MONTHS + 10*DAYS\nprint(new_date2)","lang":"python","description":"Add a DateDelta to a date to get another date."},"warnings":[{"fix":"Convert datetime to date first: some_datetime.date() + datedelta","message":"DateDelta cannot be added to datetime objects, only date objects. Attempting to add to datetime causes a TypeError.","severity":"gotcha","affected_versions":"all"},{"fix":"Be aware of month-end clamping behavior; it's by design.","message":"Adding a DateDelta with months to a date near month end can produce unexpected results (e.g., Jan 31 + 1 month = Feb 28/29). No month overflow to next month.","severity":"gotcha","affected_versions":"all"},{"fix":"Use datetime.timedelta for sub-day precision.","message":"DateDelta only supports years, months, weeks, days. No support for hours, minutes, seconds, or microseconds.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use .date() on the datetime before adding: some_datetime.date() + DateDelta(...)","cause":"DateDelta can only be added to date objects, not datetime objects.","error":"TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'DateDelta'"},{"fix":"Use 'from datedelta import DateDelta'","cause":"Attempting to import DateDelta incorrectly (e.g., import datedelta; datedelta.DateDelta) whereas the correct import is 'from datedelta import DateDelta'.","error":"AttributeError: module 'datedelta' has no attribute 'DateDelta'"},{"fix":"Use DateDelta(years=..., months=..., days=...) to construct the delta you need.","cause":"DateDelta does not support subtraction between two DateDelta objects.","error":"TypeError: unsupported operand type(s) for -: 'DateDelta' and 'DateDelta'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}