Forums » .NET » .NET »

how to find out the time difference in

Posted Date: 03 Mar 2006      Posted By:: Satheesh kumar     Member Level: Silver    Member Rank: 2209     Points: 2   Responses: 6

how to find out the time difference in

please tell me the solution as earlier as possible

thank u!

with regards


#43491    Author: ravinderreddy      Member Level: Silver      Member Rank: 0     Date: 03/Mar/2006   Rating: 2 out of 52 out of 5     Points: 2

take two strings for intime(in) and outtime(out). and write code for diff

DateDiff(DateInterval.Minute, in, out)

U will get diff between time.
All the best......

#79786    Author: Bhavesh Rana      Member Level: Silver      Member Rank: 0     Date: 22/Sep/2006   Rating: 2 out of 52 out of 5     Points: 2

TimeSpan T1=new TimeSpan(System.DateTime.Now.Day,System.DateTime.Now.Hour,System.DateTime.Now.Minute,System.DateTime.Now.Second,System.DateTime.Now.Millisecond);
//Do Your Process...

TimeSpan T2=new TimeSpan(System.DateTime.Now.Day,System.DateTime.Now.Hour,System.DateTime.Now.Minute,System.DateTime.Now.Second,System.DateTime.Now.Millisecond);

I hope this will help !!!!

Bhavesh Rana

#106089    Author: Batzoid      Member Level: Bronze      Member Rank: 0     Date: 21/Jan/2007   Rating: 2 out of 52 out of 5     Points: 2

This function will calculate the difference between two times.

Public Function TimeDiff(t1, t2)

'Purpose: Calculate the difference between two given times
' t1 and t2. Returns t1 - t2.

Dim sec1, sec2, secOut, minsOut, hoursOut

'Convert times to seconds
sec1 = (Hour(t1) * 3600) + (Minute(t1) * 60) + Second(t1)
sec2 = (Hour(t2) * 3600) + (Minute(t2) * 60) + Second(t2)

'Subtract one from the other
secOut = sec1 - sec2 ' or Add together to sum two times

'Calc hours
hoursOut = Int(secOut / 3600)
secOut = secOut - (hoursOut * 3600)

'Calc minutes
minsOut = Int(secOut / 60)
secOut = secOut - (minsOut * 60)

'Convert back to HH:MM:SS
TimeDiff = TimeValue(Format(hoursOut, "00") + ":" + Format(minsOut, "00") + ":" + Format(secOut, "00"))

End Function

#152769    Author: eugene      Member Level: Bronze      Member Rank: 0     Date: 20/Sep/2007   Rating: 2 out of 52 out of 5     Points: 2

dim ts as TimeSpan = DateTime.Now.Subtract(TimeStamp)


#240105    Author: Panamayan Purushothaman      Member Level: Gold      Member Rank: 429     Date: 30/May/2008   Rating: 2 out of 52 out of 5     Points: 2

DateDiff(DateInterval.Minute, intime, outtime)

Any kind of help will be appreciated,


#313669    Author: shinurag      Member Level: Silver      Member Rank: 3532     Date: 06/Nov/2008   Rating: 2 out of 52 out of 5     Points: 4

Dim dt1 As TimeSpan
Dim dt2 As TimeSpan
Dim dt3 As TimeSpan

dt1 = DateTimePicker1.Value.TimeOfDay
dt2 = DateTimePicker2.Value.TimeOfDay
dt3 = dt2.Subtract(dt1)

If dt3.Hours < 1 And dt3.Minutes < 1 And dt3.Seconds < 1 Then
MsgBox("Date interval mismatch")
End If

set datetimepicker's format as time
set datetimepicker's ShowUpDown as true


Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.

Next : Is there any expert to solve this?
Previous : what is difference between String and string(data type) in c#?
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages

Subscribe to Subscribers
Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Talk to Webmaster Tony John

Online Members

Lakhan Pal
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India