datevb6

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?


Solution

  • 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)