473,406 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

IsDate function is Vb.Net

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
6 25868
"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
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
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
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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: vonclausowitz | last post by:
Hi All, I use IsDate() to check a field in Outlook tasks to see if it contains a real date. If IsDate(Task.role) then ... else ... endif
3
by: Mike | last post by:
Hi, Anyone knows what the equivalent of the IsDate function is in C#? Thanks Mike
0
by: Veeresh | last post by:
I am using ISDate function to determine whether user has entred valid date or not. The below statement returns true. IsDate("12/12") is true & the system interprets this as 12/12/2004. Is...
2
by: John | last post by:
Hi all, How do I use the isDate function? The reason I ask this is because the function returns a false for a date "13/09/2004" which is correct in "dd/MM/yyyy" format. Is there another...
3
by: Andy Holliman | last post by:
Why does IsDate("01 02 03 12 2003") return true and CDate("01 02 03 12 2003") return "1 12 2003" ? Thanks Andy
2
by: Oenone | last post by:
I'm having a couple of problems with the IsDate function in VB.net (.net framework v1.1). Having searched the web and usenet for others having the same problem, I've seen several posts from people...
2
by: z. f. | last post by:
Hi, i see in reflector in inner implementation of the Microsoft.VisualBasic.Information.IsDate function that looks like that: public static bool IsDate(object Expression) { if (Expression !=...
19
by: MDC | last post by:
Why does this return true: IsDate("ISometimesHateProgrammingMarch2005") Is there another way to verify that this is not a date?? Thanks in advance! MDC
1
by: nlulla | last post by:
Hi I am trying to get all rows from a datatable where the first column F1 is a date, as this datatable is created of excel, i only want to deal with rows where the first column is having a date in...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.