Reputation: 3975
I'm getting date-time from a source as 20110731183330. I want to convert it to '7/31/2011 06:33:30 PM'. Is there a one line code for the same in vb.net?
Upvotes: 1
Views: 20373
Reputation: 3975
Dim result As Date = Date.ParseExact(dt, "yyyyMMddHHmmss", System.Globalization.CultureInfo.InvariantCulture)
then we can format it as required.
Upvotes: 0
Reputation: 227
It can be...
Dim CustomDate As Date = Date.ParseExact(yourdate, "MM/dd/yyyy hh:mm:ss tt", Globalization.DateTimeStyles.None)
Upvotes: 0
Reputation: 8699
That would be:
Dim result As Date = Date.ParseExact(datestring, "yyyyMMddHHmmss")
Upvotes: 4