date type
how do you change a String data type in to a Date format
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Lakshmanan Sethu SankaranarayanPosted Mar 7, 2014, 11:51 AM
VulpesPosted Mar 7, 2014, 11:45 AM
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
Sifumene MsanePosted Mar 7, 2014, 3:53 AM
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());