Reputation: 81292
I have the following wonderfully unreliable statement:
string LastsuccessfuldownloadDateTime = "04.07.2009 19:21:36"
DateTime myDate = Convert.ToDateTime(LastsuccessfuldownloadDateTime);
Is it possible to depict the day and month fields explicitly in the conversion? Because my month and day fields are getting swapped....
Thanks
Upvotes: 1
Views: 1633
Reputation: 171794
You can use DateTime.ParseExact():
// for European format (day followed by month)
DateTime myDate = DateTime.ParseExact(LastsuccessfuldownloadDateTime ,
"dd.MM.yyyy HH:mm:ss", null);
Upvotes: 12