Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8530721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:18:53+00:00 2026-06-11T09:18:53+00:00

What is the difference between datetime.timedelta (from Python’s standard library) and dateutil.relativedelta.relativedelta when working

  • 0

What is the difference between datetime.timedelta (from Python’s standard library) and dateutil.relativedelta.relativedelta when working only with days?

As far as I understand, timedelta only supports days (and weeks), while relativedelta adds support for periods defined in terms of years, months, weeks or days, as well as defining absolute values for year, month or day. (remember, for the purposes of this question, I don’t have to worry about hours, minutes or seconds)

Considering that I’m only working with datetime.date objects, and only interested in periods defined by the number of days, what’s the difference between timedelta and relativedelta? Is there any difference?

from datetime import date, timedelta
from dateutil.relativedelta import relativedelta

i = -1  # This could have been any integer, positive or negative
someday = date.today()
# Is there any difference between these two lines?
otherday = someday + timedelta(days=i)
otherday = someday + relativedelta(days=i)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:18:54+00:00Added an answer on June 11, 2026 at 9:18 am

    dateutil is an extension package to the python standard datetime module. As you say, it provides extra functionality, such as timedeltas that are expressed in units larger than a day.

    This is useful if you have to ask questions such as how many months can I save before my girlfriend’s birthday comes up, or what’s the last Friday in the month? This hides complex calculations that are caused by the different lengths of the months, or extra days in leap years.

    In your case, you are only interested in the number of days. So you’d best use timedelta as this avoids an extra dependency on the dateutil package.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From: http://docs.python.org/py3k/library/datetime.html#timedelta-objects A timedelta object represents a duration, the difference between two dates or
What is the formatting difference between: DateTime datetimenow = DateTime.Now.ToLocalTime(); and long ticks =
I take the difference between two DateTime fields, and store it in a TimeSpan
How do I get the time difference between two DateTime objects using C#?
I have a function that returns the difference between 2 DateTime's in seconds. However,
What is the difference between a DateTime? and a DateTime (without a question mark)
Is there any difference between Convert.ToDateTime and DateTime.Parse Which one is faster or which
I am working on Windows 7 OS and calculating the number of days between
What's the difference between DateTime and Time classes in Ruby and what factors would
How can i calculate the difference between datetime column and now (for example 'created_at'

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.