Count Days&Month&Year Between Two Years????????For Benniners

Sabarimahesh
Posted by Sabarimahesh under C# category on | Points: 40 | Views : 1097
                                                                     




1.Write this coding in Button_Click
----------------------------------------
Count "HOW Many Days between Two Year"
----------------------------------------


DateTime start = Convert.ToDateTime(textBox1.Text.ToString());

DateTime last = Convert.ToDateTime(textBox2.Text.ToString());

TimeSpan diff = last.Subtract(start);

string days = diff.Days.ToString();

textBox3.Text = days;

----------------------------------------
Count "HOW Many Year between Two Year"
----------------------------------------

if (start.DayOfYear <= last.DayOfYear)
{

label1.Text = ("Total Years" + (last.Year - start.Year));
}
else
{
label1.Text = ("Total Years" + (start.Year - last.Year));
}
-----------------------------------------
Count "HOW Many Month between Two Year"
-----------------------------------------

label2.Text = (diff.Days / 30).ToString();

Comments or Responses

Login to post response