We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 169,139 times

Related Categories

How to convert a string to a date

Finding out how to convert one type to another in .NET is tricky. Here is the answer to converting a string to a DateTime type. Notice that any of the string formats work -- how nice!

//string strDate="2002-10-03";
//string strDate="10/04/2002";
string strDate="10/05";
DateTime dt = (DateTime)(TypeDescriptor.GetConverter(new DateTime(1990,5,6)).ConvertFrom(strDate));
Response.Write("<hr>" + dt.DayOfWeek);

Edward Tanguay updates his personal web site tanguay.info weekly with code, links, quotes and thoughts on web development. Sign up for the free newsletter.

Comments