How do I get the time difference between two DateTime
objects using C#?
IF they are both UTC date-time values you can do TimeSpan diff = dateTime1 - dateTime2;
Otherwise your chance of getting the correct answer in every single possible case is zero.
You need to use a TimeSpan. Here is some sample code:
TimeSpan sincelast = TimeSpan.FromTicks(DateTime.Now.Ticks - LastUpdate.Ticks);
private void button1_Click(object sender, EventArgs e)
{
TimeSpan timespan;
timespan = dateTimePicker2.Value - dateTimePicker1.Value;
int timeDifference = timespan.Days;
MessageBox.Show(timeDifference.ToString());
}