Conversion string to date type?
How can we convert a string value into data type "Date"?
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.
khaleel shaikPosted Feb 13, 2012, 4:50 AM
DateTime dt=convert.ToDateTime(varaible Name);
Satyapriya NayakPosted Feb 1, 2012, 12:04 PM
private void Form1_Load(object sender, EventArgs e)
{
string strDate = "2002-10-03";
DateTime dtDate = Convert.ToDateTime(strDate);
or
DateTime dtDate = DateTime.Parse(strDate);
MessageBox.Show(dtDate.ToString());
}
Thanks
VulpesPosted Feb 1, 2012, 11:52 AM
You can convert a string to a DateTime using one of these methods:
Convert.ToDateTime
DateTime.Parse
DateTime.TryParse
Here are the links to the MSDN docs for these methods:
http://msdn.microsoft.com/en-us/library/xhz1w05e.aspx
http://msdn.microsoft.com/en-us/library/1k1skd40.aspx
http://msdn.microsoft.com/en-us/library/system.datetime.tryparse.aspx