Date type
how do you change a String data type in to a Date format
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sifumene Msane15 reputationPosted Mar 6, 2014, 10:53 PM EST
string strDate = "21-07-2006";
DateTimeFormatInfo dtfi = new DateTimeFormatInfo();
dtfi.ShortDatePattern = "dd-MM-yyyy";
dtfi.DateSeparator = "-";
DateTime objDate = Convert.ToDateTime(strDate, dtfi);
MessageBox.Show(objDate.ToShortDateString());
VulpesRank #55 · 29.2K reputationPosted Mar 7, 2014, 6:45 AM EST
DateTime.Parse
DateTime.ParseExact
DateTime.TryParse
DateTime.TryParseExact
For information on using these methods, check this link:
http://msdn.microsoft.com/en-us/library/system.datetime(v=vs.110).aspx
Lakshmanan Sethu SankaranarayanRank #124 · 17.7K reputationPosted Mar 7, 2014, 6:51 AM EST