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

  • Home
  • SEARCH
  • 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 7753201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:59:45+00:00 2026-06-01T11:59:45+00:00

A python/django beginner’s question: I have a datetime object (drive_date), a time object (start_time)

  • 0

A python/django beginner’s question:

I have a datetime object (drive_date), a time object (start_time) and a timedelta object (when_to_notify).

I first do this:

d = datetime.combine(l.drive_date, l.start_time)

I would then like to subtract the “when_to_notify” timedelta object from d to get a notification date and time. However, django doesn’t like this. It tells me: TypeError: unsupported operand type(s) for -: ‘datetime.time’ and ‘datetime.timedelta’

How can I subtract the time in the timedelta object from a datetime object?

  • 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-01T11:59:46+00:00Added an answer on June 1, 2026 at 11:59 am

    [moved from comment section]

    datetime.combine returns a datetime from which a datetime.timedelta can be subtracted. From the exception it seems you are trying to subtract a datetime.timedelta from a time object instead of a datetime object. Can you recheck?

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

Sidebar

Related Questions

this is the first time i use django. I'm really a beginner. And this
I have built Web sites with Python/Django and desktop applications with Objective-C/Cocoa so programming
I need to have an at-home project now that I'm working on Python/Django at
I have some knowledge of Python 3 (I'm not a beginner, but I'm not
I am learning Python and building my first web app. I have been going
I have a simple Python/Django class: class myModel(models.Model): date = models.DateTimeField() value = models.IntegerField()
I have a website (python/django) that needs to use a load of Java resources
I have an existing Python django Project running in Web Server. Now the client
I have python/django app on Heroku (Cedar stack) and would like to make it
Is there Python/Django equivalent of Ruby on Rails x.days.from_now x.years.from_now Time.now + 7.days ???

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.