cType : string to date throwing InvalidCastException (ASP) (VB.NET)

asp.net, vb.net, visual-studio-2005

Solution

Try like this

Dim dt As Date = Date.ParseExact("07/15/2014","MM/dd/yyyy", CultureInfo.InvariantCulture); 
IF dt > Date.Today Then
    'CODE HERE
END IF

Check the full documentation at msdn

Problem

I am getting exception on following lines ``` InspectionDate = "07/15/2014" If CType(InspectionDate, Date) > Date.Today Then 'Here comes my logic etc 'Here comes my logic etc 'Here comes my logic etc End If ``` When i debugged i see Date.Today = #7/15/2014# Can any one please help on this. Thanks..

Original source