Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
8
Reply
C# Multiple Time Duration Calculation
Shafiqq Aziz
Nov 1 2017 2:29 AM
310
Reply
Hi, i have a problem here which is my output for my calculation is wrong.
I have
4 dateTimePicker
using
custom format
as HH:mm named
dtpIn1, dtpOut1, dtpIn2, dtpOut2
. My target calculation are
duration
between
dtpOut1 to dtpIn1
,
duration
between
dtpOut2 to dptIn2
and total
duration
between
dtpOut1 to dtpIn2
.
I got right output on calculation dtpOut1 to dtpIn1 and dtpOut1 to dtpIn2 and got very wrong on dtpOut2 to dtpIn2. What is wrong with my code here? Can you guys help me?
Here's my code :
//Calculation for time total and time sum start
private void dtpIn1_ValueChanged(object sender, EventArgs e)
{
TimeSpan result = this.dtpIn1.Value - this.dtpOut1.Value;
this.txtTotal1.Text = result.ToString();
}
private void dtpOut2_ValueChanged(object sender, EventArgs e)
{
TimeSpan result = this.dtpIn2.Value - this.dtpOut2.Value;
this.txtTotal2.Text = result.ToString();
}
private void dtpIn2_ValueChanged(object sender, EventArgs e)
{
TimeSpan result = this.dtpIn2.Value - this.dtpOut1.Value;
this.txtSum.Text = result.ToString();
}
//Calculation for time total and time sum end
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
8
)
Next Recommended Forum
Email is not sending
Could not load the assembly 'App_Web_y2kdyxfl'.