What is timedelta in python?

0 votes
can you give an example?
May 27, 2019 in Python by Waseem
• 4,540 points
87 views

1 answer to this question.

0 votes

It represents a duration which is basically difference between dates. It can also be used for datetime manipulations.

EXAMPLE:

i = datetime.datetime(2000, 3,  11,  7, 45,  23)
j = datetime.datetime( 2019,  6, 8, 2, 45, 13)
k = j - i
print(type(k))
print("k =", k)

OUTPUT:

<class 'datetime.timedelta'>
k = 7027 days, 18:59:50
answered Aug 7, 2019 by Wajiha
• 1,950 points

Related Questions In Python

+2 votes
3 answers

what is the practical use of polymorphism in Python?

Polymorphism is the ability to present the ...READ MORE

answered Mar 31, 2018 in Python by anto.trigg4
• 3,440 points
2,390 views
+4 votes
7 answers
+1 vote
4 answers
0 votes
1 answer

What is the use of raw_input function in Python?

raw_input fuction is no longer available in ...READ MORE

answered May 2, 2018 in Python by aayushi
• 750 points
250 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,343 views
0 votes
0 answers
+4 votes
6 answers
0 votes
1 answer

Performing divison on timedelta object in python?

Refer the following piece of code: e1=datetime.timedelta(days=32, seconds=0, ...READ MORE

answered Aug 13, 2019 in Python by Wajiha
• 1,950 points
66 views
0 votes
1 answer

What is the use of join()?

Join()  function is used in threading to ...READ MORE

answered Jun 20, 2019 in Python by Wajiha
• 1,950 points
52 views