Solved

How to convert a date string to a DateTime format

Posted on 2012-03-17
3
290 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Initial get page response times and IIS8 15 61
ASP.NET MVC -Add authentication 2 35
What are the simplest ways to create a Merge Sort? 3 36
Generate Unique ID in VB.NET 21 103
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

749 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