How to convert the String to Datetime

  • Thread starter Thread starter Kylin
  • Start date Start date
Hi,
You can use

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

Hope it helps.


Sachi
 
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
 
Back
Top