How to convert the String to Datetime

G

Guest

Hi,
You can use

Convert.ToDateTime("1982-12-12");
Convert.ToDateTime("19820507");

Hope it helps.


Sachi
 
K

Katy King

From: "Kylin" <[email protected]>
| Subject: How to convert the String to Datetime
|
| eg :
| 19820507
| 1982-12-12
|

For those particular formats, you'll want DateTime.ParseExact().
For example,

DateTime.ParseExact("19820507", "yyyyMMdd",
DateTimeFormatInfo.InvariantInfo);
DateTime.ParseExact("1982-12-12", "yyyy-MM-dd",
DateTimeFormatInfo.InvariantInfo);

Katy
 

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

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top