date conversion RRS feed

  • Question

  • User-1354850087 posted

    I have a textbox (txtMyDate) in which I enter a date in the format "yyyy-MM-dd" (swedish standard). I then try to convert this to a datetime, because it will go into datetime data type in a database.

    CultureInfo culture = new CultureInfo("sv-SE");
    DateTime myDate = Convert.ToDateTime(txtMyDate.Text, culture);

    This is done in a try{}-block, and since it dosn't work it ends up in the catch{}-section saying "Input string was not in a correct format".

    What am I doing wrong?

    Tuesday, October 17, 2006 9:40 AM

All replies

  • User-1950758073 posted

    Have you tried DateTime.Parse() ?



    Tuesday, October 17, 2006 12:24 PM