'Purpose : This method would convert number format date data into date.
'Parameters : Number format string would be passed. Eg: 12281990
'Return Value : Date. Eg: 12/28/1990
Public Function Number2Date(ByVal lNum As Long) As Date
Dim strNum As String = CStr(lNum)
Dim iDay, iMon, iYear As Integer
Dim ValidDate As Date
Try
'If date is not in valid format
If strNum.Length = 7 Then
strNum = "0" + strNum
End If
iMon = CInt(strNum.Substring(0, 2))
iDay = CInt(strNum.Substring(2, 2))
iYear = CInt(strNum.Substring(4, 4))
ValidDate = New Date(iYear, iMon, iDay)
Catch ex As Exception
'ex.Message
End Try
Return ValidDate
End Function