date formatting

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a system that sends a date as 17 06 2005. Is there an easy way to
convert this to US format without parsing through the text?

I would like to:

str = "17 06 2005"

dat = Cdate(str, <someformat>)

There must be a way in .Net to convert from a European format to a US date
without writing my own function?
 
I have a system that sends a date as 17 06 2005. Is there an easy way to
convert this to US format without parsing through the text?

I would like to:

str = "17 06 2005"

dat = Cdate(str, <someformat>)

There must be a way in .Net to convert from a European format to a US date
without writing my own function?

DateTime.ParseExact is what you're looking for.

dat= DateTime.ParseExact(str, "dd MM yyyy", Nothing)

(The third parameter is an IFormatProvider based on the current culture. It
would be used to provide the names of the months, or days of the week, etc.
In your case you have no names, just numbers, so it has nothing to offer,
so passing Nothing makes it use the current culture instead.)
 
Back
Top