convert to DateTime

T

Thomas Lindroos

how to convert this???


string strDate = "19701105";
DateTime myDate = System.Convert.ToDateTime(strDate);

ideas anyone

/thomas lindroos
 
J

Jon Skeet [C# MVP]

Thomas Lindroos said:
how to convert this???
string strDate = "19701105";
DateTime myDate = System.Convert.ToDateTime(strDate);

Hvae a look at DateTime.Parse and DateTime.ParseExact, where you can
specify your own format.
 
J

James Black

Thomas said:
string strDate = "19701105";
DateTime myDate = System.Convert.ToDateTime(strDate);
If you know the format is set, then just take a substring of the
first 4 characters, turn it into an int, and set DateTime by using the
year, month and day.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top