Convert string to datetime
-
Hi, I have a string with the format yyyymmdd. I'm trying to convert it to date time by DateTime.Parse(myString), but i'm getting an error. How can i convert it?
DateTime.ParseExact("20011215", "yyyyMMdd"); //note the capital M's
Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost
-
DateTime.ParseExact("20011215", "yyyyMMdd"); //note the capital M's
Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost
Ennis Ray Lynch, Jr. wrote:
DateTime.ParseExact("20011215", "yyyyMMdd"); //note the capital M's
What about the IFormatProvider at the constructor? There is no constructor at the ParseExact that takes 2 parameters
modified on Wednesday, June 15, 2011 3:37 PM
-
Ennis Ray Lynch, Jr. wrote:
DateTime.ParseExact("20011215", "yyyyMMdd"); //note the capital M's
What about the IFormatProvider at the constructor? There is no constructor at the ParseExact that takes 2 parameters
modified on Wednesday, June 15, 2011 3:37 PM
DateTime d = DateTime.ParseExact("20011215", "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
Help a brotha out and vote Managing Your JavaScript Library in ASP.NET as the best ASP.NET article of May 2011.
-
DateTime d = DateTime.ParseExact("20011215", "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
Help a brotha out and vote Managing Your JavaScript Library in ASP.NET as the best ASP.NET article of May 2011.
-
Hi, I have a string with the format yyyymmdd. I'm trying to convert it to date time by DateTime.Parse(myString), but i'm getting an error. How can i convert it?
In addition to the other answers, there is also Convert.ToDateTime(something) Always nice to know different methods of doing something.
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life. My Mu[sic] My Films My Windows Programs, etc.
-
In addition to the other answers, there is also Convert.ToDateTime(something) Always nice to know different methods of doing something.
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life. My Mu[sic] My Films My Windows Programs, etc.
That would not help in this case.
Help a brotha out and vote Managing Your JavaScript Library in ASP.NET as the best ASP.NET article of May 2011.
-
Hi, I have a string with the format yyyymmdd. I'm trying to convert it to date time by DateTime.Parse(myString), but i'm getting an error. How can i convert it?
-
That would not help in this case.
Help a brotha out and vote Managing Your JavaScript Library in ASP.NET as the best ASP.NET article of May 2011.
Probably not, but I don't know all the possible Culture formats available. There might be one out there who decided to use sensible dates.
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life. My Mu[sic] My Films My Windows Programs, etc.