Question: I have a string like this and I want to convert it to DateTime format(MM/dd/yyyyTHH:mm:ss).
but it fails, Please let me know where I'm wrong.

```
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

string stime = "4/17/2014T12:00:00";
DateTime dt = DateTime.ParseExact(stime, "MM/dd/yyyyTHH:mm:ss", CultureInfo.InvariantCulture);

```

This is the code, how I'm setting this string:

```
string startHH = DropDownList1.SelectedItem.Text;
string startMM = DropDownList2.SelectedItem.Text;
string startSS = DropDownList3.SelectedItem.Text;
string starttime = startHH + ":" + startMM + ":" + startSS;
string stime = StartDateTextBox.Text + "T" + starttime;

```

Getting this exception

```
String was not recognized as a valid DateTime.

```

Answer: 
You wrote `MM` in your format string, which means that you need a two digit month. If you want a one digit month, just use `M`.

```
DateTime dt = DateTime.ParseExact(stime, "M/dd/yyyyTHH:mm:ss", CultureInfo.InvariantCulture);

```

The other solution is to change your string to match your format.

```
string stime = "04/17/2014T12:00:00";
DateTime dt = DateTime.ParseExact(stime, "MM/dd/yyyyTHH:mm:ss", CultureInfo.InvariantCulture);

```

The key to this is remembering you're doing [parse *exact*.](http://msdn.microsoft.com/en-us/library/ms131038%28v=vs.110%29.aspx) Therefore, you must exactly match your string with your format.
Pay attention your date string contains only 1 digit for month but your patters defines `MM`.  

So either use month `04` or change pattern to `M`.