Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 334
  • Last Modified:

calculate renewal date

I've got to calculate the renewal date when the begindate begins per the given terms. I'm not sure how to go about it with due to the datatypes.

textbxBeginDate as Calendar   07/10/2011   datetime
textbxTerms as numeric   12     int
------
textbxRenewDate as Calendar   07/10/2012   datetime
0
fwstealer
Asked:
fwstealer
1 Solution
 
fwstealerAuthor Commented:
tried this but not right
protected void getExpDt()
        {
            int terms = 0;
            DateTime programStartDt;
            DateTime expDt;

            if (textbxBeginDate.Text == "")
            {
                textbxRenewDate.Text = "";
            }
            else
            {
                programStartDt = Convert.ToDateTime(textbxBeginDate.Text);

                if (textbxTerms.Text == "")
                {
                    terms = 0;
                }
                else
                {
                    terms = Convert.ToInt32(textbxTerms.Text);
                    expDt = programStartDt.AddYears(terms);
//not quite right 4/2/2012 and 12 = 4/2/2024

                    textbxRenewDate.Text = expDt.ToString();
                }
            }  
        }
0
 
wdosanjosCommented:
It seems 12 is the number of months.  So you should have expDt = programStartDt.AddMonths(terms); instead.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now