when i'm using isdate()
method in .net. returns invalid result. why "ad05ad09" read date. following code i'm using. please give me proper reason this
dim value string value = "ad05ad09" if isdate(value) dim odate date odate = cdate(value) msgbox(format(odate, "yyyy-mm-dd")) else msgbox("a") end if
as writtern in msdn:
isdate returns true if expression of date data type or can converted date; otherwise, returns false.
but should go common ways, datetime.parse
, datetime.parseexact
, convert.todatetime
, more.
see msdn example:
dim datevalue date dim datestring string = "2/16/2008" try datevalue = date.parse(datestring) console.writeline("'{0}' converted {1}.", datestring, datevalue) catch e formatexception console.writeline("unable convert '{0}'.", datestring) end try
Comments
Post a Comment