Difference between two datetime

iknowyou

Active member
Joined
Jun 14, 2011
Messages
37
Programming Experience
1-3
How can I get the difference of this two Date time.

(6/21/2011 7:02:53 AM) subtract by (6/21/2011 4:00:00 AM)

the answer should be ---> 03:02:53

Please Help...
 
Got it now. Here is the code.

Dim fDate As DateTime = "6/21/2011 7:02:53 AM"
Dim secondDate As DateTime = "6/21/2011 4:00:00 AM"

Dim totalTime As TimeSpan = fDate.Subtract(secondDate)

Console.WriteLine(totalTime.ToString())
 
or using ordinary subtraction operator:
Dim difference = fDate - secondDate
 
Back
Top