johsns
johsns

Reputation: 61

how to convert string into date? visual basic

I need to convert a date type:

13/09/2014 19:20:32

13: day, 9: month, 2014:year, 19 hours, 20:minutes, 32:second

I used this code:

Dim data_convert As Date = Date.ParseExact(data_decripted, "dd/MM/yyyy hh/mm/ss", System.Globalization.DateTimeFormatInfo.InvariantInfo)

but tells me that the string is not recognized as a valid datetime value. How is this possible?

Upvotes: 0

Views: 1085

Answers (1)

Avinash Babu
Avinash Babu

Reputation: 6252

I'm not a vb.net developer. After searching your requirement I have found this.

You would need to use Date.ParseExact.

Dim edate = "dd/mm/yyyy" 

Dim expenddt As Date = Date.ParseExact(edate, "dd/MM/yyyy",

    System.Globalization.DateTimeFormatInfo.InvariantInfo)

Upvotes: 1

Related Questions