I have a question people..plz help me...here are the code lines.....
public partial class Form1 : Form
{
public DateTime today = System.DateTime.Today;
public DateTime FinalDayOfPayment= Convert.ToDateTime("1/12/2011");
public TimeSpan noOfDays;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
label1.Text = today.ToString();
label2.Text = FinalDayOfPayment.ToString();
noOfDays = today - FinalDayOfPayment;
label3.Text = noOfDays.ToString();
}
}
This gives me the no of days...but a want to get the no of months..
Is there any other way to get it..???
Loading
VulpesPosted Apr 14, 2011, 8:51 AM
Raja KrishnamurthyPosted Apr 14, 2011, 8:21 AM
int differenceInMonths = Math.Abs(12 * (FinalDayOfPayment.Year - today.Year) + FinalDayOfPayment.Month - Today.Month) //will work if the Final Date is lesser than today too and any year
HTH
Suthish NairPosted Apr 14, 2011, 10:23 AM
DateTime today = System.DateTime.Today;