How do I convert date and time into fraction of days format ?
To be clearer, I have date and time like "26 days,0:16:53". Is there any way to convert this into one number that would be the equivalent value of the above in the format of days only ( fraction value). Example 26.XXXX where 'XXXX' is the fraction of a day corresponding to "0:16:53" in the above example. Is there any way to do this ?
Any help is appreciated.
Thanks in advance
Well, it should be something like this:
dt = timedelta(days=26, hours=0, minutes=16, seconds=53)
secs_per_day = 24*60*60 # hours * mins * secs
dt.total_seconds()/secs_per_day
>>>26.011724537037036
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With