How to conver an especific Format to DateTime

G

Guest

Hi!
I'm try to convert a String to Datetime, but convert only works for some format:
my value is:
"20040719 16:00"
This is the String that I want to convert to Datetime.
I testing with some culture and the closet fromat was this
Dim culture As CultureInfo = New CultureInfo("ja-JP")
that convet from 2004/07/19 16:00
But doesn't work without Separators
Also try next
Dim myCI As New CultureInfo("en-US", False)
Dim myCIclone As CultureInfo = CType(myCI.Clone(), CultureInfo)
myCIclone.DateTimeFormat.DateSeparator = ""

But send me and error, what can I do.
Somebody can help me?
Thanks in advance.
 
N

Nick Malik

Air code... but it should be close

Dim newDT as DateTime
Dim myDateString as String
Dim myCulture As CultureInfo = New CultureInfo("en-US")

myDateString = "20040719 16:00"
newDT = DateTime.ParseExact(myDateString,"yyyyMMdd hh:mm", myCulture)

--- Nick
 

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

Top