Problem with date type
Hi All,
I want convert the string type to date type but i am getting error.
Dim sDate as String = "12/15/2008"
Dim dAttrDate AsDate = "#" & sDate & "#"
the below error :
System.InvalidCastException: Conversion from string "#12/15/2008#" to type 'Date' is not valid.
at Microsoft.VisualBasic.CompilerServices.Conversions .ToDate(String Value)
I am doing this because i want to fomat the date in below format after converting to date Type:
Dim dDate As New java.util.Date(CInt(Format(dAttrDate, "yyyy")) - 1900, _
CInt(Format(dAttrDate, "MM")) - 1, _
CInt(Format(dAttrDate, "dd")), _
CInt(Format(dAttrDate, "hh")), _
CInt(Format(dAttrDate, "mm")), _
CInt(Format(dAttrDate, "ss")))
How to avoid the above error.
Thanks
Nelly
|