Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Starttime=10:25:06 AM
EndTime=1:25:06 PM
result=Starttime.substract(EndTime)
Result=8:00:00

Result is wrong
please help me

What I have tried:

Starttime=10:25:06 AM
EndTime=1:25:06 PM
result=Starttime.substract(EndTime)
Result=8:00:00

Result is wrong 
please help me
Posted
Updated 15-May-17 20:42pm

There's few ways to achieve that:

#1
DateDiff Function (Visual Basic)[^]

#2
Get time difference between two timespan in vb.net - Stack Overflow[^]

For further details, i'd suggest to read MSDN documentation: Performing Arithmetic Operations with Dates and Times[^]
 
Share this answer
 
v2
Comments
Suvendu Shekhar Giri 16-May-17 2:43am    
Nice references. Should be helpful for OP. 5Ed!
Maciej Los 16-May-17 2:44am    
Thank you.
You can try something like following-
VB
Dim Starttime As New DateTime(2017, 1, 1, 10, 25, 6)     ' 10:25:06 AM
Dim EndTime As New DateTime(2017, 1, 1, 13, 25, 6)     ' 1:25:06 PM

Dim Result As TimeSpan = EndTime - Starttime

Hope, it helps :)
 
Share this answer
 
Comments
Maciej Los 16-May-17 2:45am    
+5! for effort as it's a part of my answer ;)
Suvendu Shekhar Giri 16-May-17 2:47am    
Thanks :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900