Dim string_date As String
string_date="31/03/2014"
how to convert string_date to date in "dd/MM/yyyy" format to compare with current date
Dim string_date As String
string_date="31/03/2014"
how to convert string_date to date in "dd/MM/yyyy" format to compare with current date
Use DateTime.TryParseExact():
Dim string_date As String = "31/03/2014"
Dim dt As DateTime
If DateTime.TryParseExact(string_date, "dd/MM/yyyy", Nothing, Globalization.DateTimeStyles.None, dt) Then
Debug.Print("dt = " & dt.ToString("D"))
If dt.Equals(DateTime.Today) Then
Debug.Print("Equal to Today")
Else
Debug.Print("Not Equal to Today")
End If
End If
Finally, I got my own solution.
d1 as date
string_date as string
string_date="31/03/2014"
d1 = Date.ParseExact(string_date, "dd/MM/yyyy", Globalization.CultureInfo.InvariantCulture)