Solved

How to convert a date string to a DateTime format

Posted on 2012-03-17
3
288 Views
Last Modified: 2012-03-17
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
Comment
Question by:Dovberman
3 Comments
 
LVL 14

Expert Comment

by:systan
ID: 37733222
DateTime dteSplitDate = strSplitDate.ToString("yyyy-MM-dd");
0
 
LVL 14

Accepted Solution

by:
nishant joshi earned 500 total points
ID: 37733241
strSplitDate=(Convert.ToDateTime(strSplitDate).ToString("yyyy-MM-dd");
Regards,
nishant
0
 

Author Closing Comment

by:Dovberman
ID: 37733296
strSplitDate.ToString("yyyy-MM-dd") throws an error.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question