datedelta(datestr=None, days=0, months=0, years=0, weeks=0, dt1=None, dt2=None, as_date=None, **kwargs)[source]#

Perform calculations on a date string (or date object), returning a string (or a date). Wrapper to dateutil.relativedelta.relativedelta().

If datestr is None, then return the delta object rather than the new date.

  • datestr (None/str/date/list) – the starting date (typically a string); if None, return the relative delta

  • days (int) – the number of days (positive or negative) to increment

  • months (int) – as above

  • years (int) – as above

  • weeks (int) – as above

  • dt1 (dates) – if both provided, compute the difference between them

  • dt2 (dates) – if both provided, compute the difference between them

  • as_date (bool) – if True, return a date object; otherwise, return as input type

  • kwargs (dict) – passed to


sc.datedelta('2021-07-07', 3) # Add 3 days
sc.datedelta('2021-07-07', days=-4) # Subtract 4 days
sc.datedelta('2021-07-07', weeks=4, months=-1, as_date=True) # Add 4 weeks but subtract a month, and return a dateobj
sc.datedelta(days=3) # Alias to du.relativedelta.relativedelta(days=3)
New in version 3.0.0: operate on list of dates
New in version 3.1.0: handle all date input formats