Solved

How to convert a date string to a DateTime format

Posted on 2012-03-17
3
291 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

691 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