Comparing a time delta in python
Posted
by Alpesh Patel
on Stack Overflow
See other posts from Stack Overflow
or by Alpesh Patel
Published on 2010-04-07T11:07:49Z
Indexed on
2010/04/07
11:13 UTC
Read the original article
Hit count: 320
I have a variable which is <type 'datetime.timedelta'>
and I would like to compare it against certain values.
Lets say d produces this datetime.timedelta
value 0:00:01.782000
I would like to compare it like this:
#if d is greater than 1 minute
if d>1:00:
print "elapsed time is greater than 1 minute"
I have tried converting datetime.timedelta.strptime()
but that does seem to work. Is there an easier way to compare this value?
© Stack Overflow or respective owner