By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,697 Members | 1,286 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,697 IT Pros & Developers. It's quick & easy.

IsDate function is Vb.Net

P: n/a
IsDate("01/01") in Vb.Net is returning TRUE. Is it a bug in the function?
What is the other way of checking the same functionality? Is there any other
know issue with the date function.
..Net 1.1 Framework.
I know alternative way of checking the same "If TypeOf MyVariable Is
DateTime Then"
Thanks,
Smith
Nov 21 '05 #1
Share this Question
Share on Google+
6 Replies

P: n/a
"Peter Smith" <Pe*********@hotmail.com> schrieb
IsDate("01/01") in Vb.Net is returning TRUE. Is it a bug in the
function? What is the other way of checking the same functionality?
Is there any other know issue with the date function.
.Net 1.1 Framework.
I know alternative way of checking the same "If TypeOf MyVariable Is
DateTime Then"

I don't see a bug. It is a valid date. It's the first of January. The year
is 2005 because it is not specified.
Armin

Nov 21 '05 #2

P: n/a
Then what about this?
IsDate("01/2005"). This is also january first 2005?
Thanks,
Smith
"Armin Zingler" <az*******@freenet.de> wrote in message
news:uI**************@TK2MSFTNGP14.phx.gbl...
"Peter Smith" <Pe*********@hotmail.com> schrieb
IsDate("01/01") in Vb.Net is returning TRUE. Is it a bug in the
function? What is the other way of checking the same functionality?
Is there any other know issue with the date function.
.Net 1.1 Framework.
I know alternative way of checking the same "If TypeOf MyVariable Is
DateTime Then"

I don't see a bug. It is a valid date. It's the first of January. The year
is 2005 because it is not specified.
Armin

Nov 21 '05 #3

P: n/a
In article <ut**************@TK2MSFTNGP14.phx.gbl>, Peter Smith wrote:
IsDate("01/01") in Vb.Net is returning TRUE. Is it a bug in the function?
What is the other way of checking the same functionality? Is there any other
know issue with the date function.
.Net 1.1 Framework.
I know alternative way of checking the same "If TypeOf MyVariable Is
DateTime Then"
Thanks,
Smith


As Armin suggests, this is not a bug. Most likely, though I haven't
really bothered to check, the IsDate function most is a wrapper
for the DateTime.Parse function. And, if you read the remarks on this
function in the documentation, I would expect this behavior.

Basically, it says that the DateTime.Parse function uses the information
in the DateTimeFormatInfo for the current culture. As it parses, it
will FILL in any missing values (month, day, year) with the
values from the current date... Meaning that, the DateTime.Parse will
turn your string:

"01/01" into a date of "01/01/05". And that, is a valid date.

--
Tom Shelton [MVP]
Nov 21 '05 #4

P: n/a
In article <u6**************@TK2MSFTNGP12.phx.gbl>, Peter Smith wrote:
Then what about this?
IsDate("01/2005"). This is also january first 2005?
Thanks,
Smith


See my previous post... Esentially, DateTime.Parse will interpret that
as January 20, 2005 (basically, adding todays day in). Again, it will
return a valid date, so the IsDate Function will return true.

--
Tom Shelton [MVP]
Nov 21 '05 #5

P: n/a
In article <ut**************@TK2MSFTNGP14.phx.gbl>, Peter Smith wrote:
IsDate("01/01") in Vb.Net is returning TRUE. Is it a bug in the function?
What is the other way of checking the same functionality? Is there any other
know issue with the date function.
.Net 1.1 Framework.
I know alternative way of checking the same "If TypeOf MyVariable Is
DateTime Then"
Thanks,
Smith


One more note... If this is a problem for you - you could always write a
replacement using DateTime.ParseExact. ParseExact will only return a
date if the date is in the specified format. So, in psuedo code it
would look something like:

public function myIsDate (date as string) as boolean
try
datetime.parseexact (....)
return true
catch
return false
end try
end fuction

--
Tom Shelton [MVP]
Nov 21 '05 #6

P: n/a
"Peter Smith" <Pe*********@hotmail.com> schrieb
Then what about this?
IsDate("01/2005"). This is also january first 2005?


Yes:
Msgbox CDate("01/2005")

Tom's reply answers why.

If you don't like the flexibilty of the function - you are not the only
one - you can write one on your own (or find one for free).
Armin

Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.