Oladotun Obileye

Oladotun Obileye

  • NA
  • 98
  • 19.3k

How to work with int and datetime in C#

May 26 2019 2:24 AM
Good day everyone please i am working on an application. i want the user to be able to enter the amount of loan they want to borrow, and if the loan is within 1 year it should work. so depending on the months the user is going to borrow the loan. for 6months or lesser the program should multiply the amount entered by the user by 5% within six - nine months 7.5% of the money the user enter e.tc. so if the datatimepicker(days) difference is lesser than 6months(before) but i am getting error
 
int result;
DateTime reqdt = dtrequest.Value.Date;
DateTime retdt = dtreturn.Value.Date;
DateTime before = reqdt.AddMonths(6);
DateTime within = reqdt.AddMonths(9);
DateTime after = reqdt.AddYears(1);
TimeSpan ts = retdt - reqdt;
int days = ts.Days;
DateTime cde = new DateTime(days);................int days to time
// DateTime cde = Convert.ToDateTime(days);
result = Convert.ToInt32(txtamount.Text);....................converting string to int(error not in the correct format)
if (cde <= before)
{
int mult = result * 5;
txtresult.Text = mult.ToString();
}
 

Answers (2)