tags:

views:

289

answers:

1

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

+11  A: 

You can use DateTime.ParseExact():

// for European format (day followed by month)
DateTime myDate = DateTime.ParseExact(LastsuccessfuldownloadDateTime , 
                                      "dd.MM.yyyy HH:mm:ss", null);
Philippe Leybaert
Thanks, that's exactly what was required...
JL