How to convert a date string to a DateTime format

I have a string value of "03/08/2012"

This needs to be converted to a Date Time format "yyyy-mm-dd"
Waht is the correct C# syntax?

This is what i have that throws an error.

 DateTime dteSplitDate =
                    DateTime.ParseExact(strSplitDate, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);

Thanks
DovbermanAsked:
Who is Participating?
 
nishant joshiConnect With a Mentor Technology Development ConsultantCommented:
strSplitDate=(Convert.ToDateTime(strSplitDate).ToString("yyyy-MM-dd");
Regards,
nishant
0
 
systanCommented:
DateTime dteSplitDate = strSplitDate.ToString("yyyy-MM-dd");
0
 
DovbermanAuthor Commented:
strSplitDate.ToString("yyyy-MM-dd") throws an error.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.