>>> import datetime
>>> datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
>>> a='2014-11-19 15:53:42'
>>> b='2015-11-19 15:53:42'
How to calculate number of hours between these two dates (a,b),which method i can follow
Hello, have you tried using the .total_seconds() function?
delta = (b-a).total_seconds()
This function returns the seconds between two dates. After that, you need to convert it to hours.
Take a look at this.. http://stackoverflow.com/questions/4362491/how-do-i-check-the-difference-in-seconds-between-two-dates
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
|Asked: 11/19/14, 5:30 AM|
|Seen: 706 times|
|Last updated: 3/16/15, 8:10 AM|