Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
datetime / time
#6
(Feb-01-2021, 12:45 AM)Larz60+ Wrote: It is not working because it is not indented properly.
He has edit his post and fixed indentation.
The reason why it not work now is what i explain in my post.

Just one more point ifigazsi you should not use bare except:
Now it hide the real error and just print error,which tell you nothing.
import datetime

t = datetime.time(7, 0)
d = datetime.datetime(2021, 1, 1, 7, 0)
min_delta = datetime.timedelta(minutes=45)
print(t + min_delta)
Error:
Traceback (most recent call last): File "<module4>", line 6, in <module> TypeError: unsupported operand type(s) for +: 'datetime.time' and 'datetime.timedelta'
ifigazsi and buran like this post
Reply


Messages In This Thread
datetime / time - by ifigazsi - Jan-31-2021, 07:31 PM
RE: datetime / time - by Larz60+ - Jan-31-2021, 07:44 PM
RE: datetime / time - by ifigazsi - Jan-31-2021, 08:51 PM
RE: datetime / time - by snippsat - Jan-31-2021, 09:00 PM
RE: datetime / time - by Larz60+ - Feb-01-2021, 12:45 AM
RE: datetime / time - by snippsat - Feb-01-2021, 01:21 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Assign a value if datetime is in between a particular time limit klllmmm 2 2,823 Jan-02-2021, 07:00 AM
Last Post: klllmmm
  TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'str' findbikash 2 9,725 Sep-18-2019, 08:32 AM
Last Post: buran
  Convert from datetime to time.struct_time object chris0147 0 4,447 Mar-11-2018, 12:01 AM
Last Post: chris0147
  Subtract Minutes from Datetime.Time tkj80 2 43,162 May-11-2017, 09:56 AM
Last Post: klllmmm

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020