converting timedelta to float

0 votes
How do I convert the timedelta duration into float value?
Aug 8, 2019 in Python by Fata
• 1,050 points
6,364 views

1 answer to this question.

0 votes

Use the following piece of code:

x1=datetime.timedelta(days=3000, seconds=0, microseconds=0, milliseconds=0, minutes=40, hours=5, weeks=8)
x2=datetime.timedelta(days=345, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=4, weeks=8)
x3=x1-x2
x5 = x3.total_seconds()
print(x5)

OUTPUT:

229398000.0
answered Aug 8, 2019 by Wajiha
• 1,960 points

Related Questions In Python

+1 vote
1 answer

Converting integers to strings

Yes you can convert integers to strings ...READ MORE

answered Jul 1, 2019 in Python by Nisa
• 1,090 points
607 views
0 votes
1 answer

How do I parse a string to a float or int?

Hii, Python method to check if a string ...READ MORE

answered Apr 13, 2020 in Python by Niroj
• 82,840 points
1,020 views
0 votes
1 answer

How to check if a float value(decimal number) is between range(0 to 10) in python

Hello,  A function that returns True for an integer number (int or ...READ MORE

answered Sep 14, 2020 in Python by Niroj
• 82,840 points
7,139 views
0 votes
1 answer

How to list a column of float values from csv file without importing (Python)

Using the default CSV module Demo: import csv with open(filename, "r") ...READ MORE

answered Sep 16, 2020 in Python by Rajiv
• 8,870 points
8,963 views
0 votes
1 answer

Converting integer to string in Python

In order to convert an object to string ...READ MORE

answered Feb 11, 2022 in Python by Dev
• 6,000 points
607 views
0 votes
1 answer

ValueError: could not convert string to float: id

The problem is that in your code ...READ MORE

answered Apr 28, 2022 in Python by narikkadan
• 63,600 points
8,757 views
0 votes
1 answer

converting string into datetime

You can make use of asctime() method ...READ MORE

answered Aug 7, 2019 in Python by Wajiha
• 1,960 points
583 views
0 votes
1 answer

timedelta in years

Use the following piece of code: x1=datetime.timedelta(days=3000, seconds=0, ...READ MORE

answered Aug 8, 2019 in Python by Wajiha
• 1,960 points
14,484 views
0 votes
1 answer

What is timedelta in python?

It represents a duration which is basically ...READ MORE

answered Aug 7, 2019 in Python by Wajiha
• 1,960 points
776 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP