views:

150

answers:

1
import datetime
start = datetime.datetime(2009, 1, 31)
end = datetime.datetime(2009, 2, 1)
print end-start
>>1 day, 0:00:00//output

How to get the output in minutes

Thanks,

+2  A: 
import datetime
start = datetime.datetime(2009, 1, 31)
end = datetime.datetime(2009, 2, 1)
diff = end-start
print (diff.days * 1440) + (diff.seconds / 60)
>> 1440.0

(I'm assuming you don't need microsecond resolution here - but if you do, just add in a third term using diff.microseconds with the proper divisor to convert to minutes.)

Amber
what is the unit 1440? here
Hulk
@Hulk: minutes per day
SilentGhost
Thanks.................
Hulk