Amol88 Amol88 - 1 month ago 11
Vb.net Question

How to convert string date (25.04.2016) to date format (mm/dd/yyyy)?

I have string date (25.05.2016) ,i want to convert it into (mm/dd/yyyy) format in VB.net.
Please suggest solution.

Answer

Use ParseExact with the format you need to get the string into a date variable, then .ToString to convert to another format:

Dim dateString As String = "25.05.2016"
Dim dateFormat As String = "dd.MM.yyyy"
Dim dateValue = DateTime.ParseExact(dateString, dateFormat, CultureInfo.InvariantCulture)

Debug.WriteLine(dateValue.ToString("MM/dd/yyyy"))

The list of custom datetime formats can be found here