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
3,945 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,950 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
211 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,780 points
361 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,780 points
4,701 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,910 points
5,682 views
0 votes
1 answer

Converting integer to string in Python

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

answered Feb 11 in Python by Dev
• 6,000 points
52 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 in Python by narikkadan
• 21,680 points
3,540 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,950 points
190 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,950 points
11,872 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,950 points
243 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