[Solved] Hours and time converting to a certain format [closed]

This can be done conveniently by using the appropriate representation for your fractional hours, namely a timedelta. If the input is of datatype string, convert to float first. Ex: from datetime import datetime, timedelta for td in [8.25, 17.75]: # add the duration as timedelta to an arbitrary date to get a time object: print((datetime(2020,1,1) … Read more