Posts Topics Forums Images
Search videos from message boards Videos Search messages from microblogs Microblogs Search messages from imdb.com Imdb Search messages from yuku.com Yuku Search messages from lefora.com (free forums) Lefora
My account: Login | Sign Up
Loading... 

Thread: Best way for duration - time pasted

Started 1 month, 2 weeks ago by invader7
Hello, i want to ask you which is the best way to keep duration between two events for example 2 buttons press... I want the first to get the current time Code: DateTime.Now and the second do the same and then calculate the duration, i managed to do this but i have some problems... if the first button is pressed 23:00:00 (hour/minutes/sec) and the second button is pressed at 01:...
Site: CodeGuru Forums - A Developer.com Community for C++, C#, VB, Java and .NET Solutions  CodeGuru Forums - A Developer.com Community for C++, C#, VB, Java and .NET Solutions - site profile
Forum: C-Sharp Programming  C-Sharp Programming - forum profile
Total authors: 5 authors
Total thread posts: 9 posts
Thread activity: no new posts during last week
Domain info for: codeguru.com

Other posts in this thread:

Arjay replied 1 month, 2 weeks ago
Look at using TimeSpan.

Mutant_Fruit replied 1 month, 2 weeks ago
DateTime prev = DateTime.Now; ... // some time later ... TimeSpan diff = DateTime.Now - prev;

BigEd781 replied 1 month, 2 weeks ago
Use a TimeSpan: Code: DateTime start = DateTime.Now; ... DateTime end = DateTime.Now; TimeSpan span = end - start; EDIT: ninja'd

invader7 replied 1 month, 2 weeks ago
thanks all of you, thanks

invader7 replied 1 month, 2 weeks ago
Code: TimeSpan diff = DateTime.Now - DateTime.Parse(chargedataGridView.Rows[oRow.Index] .Cells[1].Value.ToString()) ; TimeSpan duration = new TimeSpan(diff.Hours, diff.Minutes, diff.Seconds); chargedataGridView.Rows[oRow.Index] .Cells[1].Value = duration.ToString(); i have this, it doesn't works if the first event is 23:00:00 and the second 1:00:00 and because i have it on a timer it ...

boudino replied 1 month, 2 weeks ago
There is also Stopwatch class.

Mutant_Fruit replied 1 month, 2 weeks ago
"DateTime.Parse(chargedataGridView.Rows[oRow.Index ].Cells[1].Value.ToString()) " And what value do you expect that to give you? Did you check the output of that function call?

invader7 replied 1 month, 2 weeks ago
pfff my bad i understand what you mean about what it gives me... you are right.. ill solve it now thanks..

 

Top contributing authors

Name
Posts
invader7
4
user's latest post:
Best way for duration - time pasted
Published (2009-11-04 06:52:00)
pfff my bad i understand what you mean about what it gives me... you are right.. ill solve it now thanks..
Mutant_Fruit
2
user's latest post:
Best way for duration - time pasted
Published (2009-11-04 06:10:00)
"DateTime.Parse(chargedataGridView.Rows[oRow.Index].Cells[1].Value.ToString()) " And what value do you expect that to give you? Did you check the output of that function call?
BigEd781
1
user's latest post:
Best way for duration - time pasted
Published (2009-11-03 16:31:00)
Use a TimeSpan: Code: DateTime start = DateTime.Now; ... DateTime end = DateTime.Now; TimeSpan span = end - start; EDIT: ninja'd
Arjay
1
user's latest post:
Best way for duration - time pasted
Published (2009-11-03 16:14:00)
Look at using TimeSpan.
boudino
1
user's latest post:
Best way for duration - time pasted
Published (2009-11-04 02:11:00)
There is also Stopwatch class.

Related threads on "CodeGuru Forums - A Developer.com Community for C++, C#, VB, Java and .NET Solutions":

Related threads on other sites:

Thread profile page for "Best way for duration - time pasted" on http://www.codeguru.com. This report page is a snippet summary view from a single thread "Best way for duration - time pasted", located on the Message Board at http://www.codeguru.com. This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity