Skip to content

Convert from sting to date

elsabbah ahmed

Asked May 26, 2012, 8:05 AM EDTSolved
Share
LinkedInX
I try to pass some variable from visual studio .net (C#) to database through storedprocedure ,
but i have problem with convert from string to date

can i find some help?

thank you all


C#
protected void AddButton_Click(object sender, EventArgs e)
 {


      int rowsaffected = MainTable.InsertIntoMainTable(int.Parse(DistDropDownList.SelectedValue), myDate, int.Parse(DiseaseDropDownList.SelectedValue), int.Parse(CasesTextBox.Text), int.Parse(GovDropDownList.SelectedValue));

        if (rowsaffected > 0)
        {
            ResultLabel.Text = "New Row Added";


        }
        else
        {
            ResultLabel.Text = "No Rows Added";
        }
    }

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Senthilkumar
    ✓ Accepted answer0
    Hi,

    You can convert string to date time by

    string date = "01/08/2008";
    DateTime dt = Convert.ToDateTime(date);


    0
  • 0
    thanks for your help it worked Accepted Answer
    0