• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 298
  • Last Modified:

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
0
Dovberman
Asked:
Dovberman
1 Solution
 
systanCommented:
DateTime dteSplitDate = strSplitDate.ToString("yyyy-MM-dd");
0
 
nishant joshiTechnology Development ConsultantCommented:
strSplitDate=(Convert.ToDateTime(strSplitDate).ToString("yyyy-MM-dd");
Regards,
nishant
0
 
DovbermanAuthor Commented:
strSplitDate.ToString("yyyy-MM-dd") throws an error.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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