|
-
Mar 21st, 2007, 04:13 AM
#1
Thread Starter
Addicted Member
When is a date not a date?
Can anyone give me a convincing explanation why this returns True in both cases?
Debug.Print IsDate("59/12/08")
Debug.Print IsDate("39/11/06")
Another light-hearted post from Guru 
-
Mar 21st, 2007, 04:16 AM
#2
Thread Starter
Addicted Member
Re: When is a date not a date?
I know why; it guesses at the year!
Another light-hearted post from Guru 
-
Mar 21st, 2007, 04:19 AM
#3
Re: When is a date not a date?
According to MS:
Function IsDate(Expression) As Boolean
Member of VBA.Information
Returns True if an expression can be converted to a date
-
Mar 21st, 2007, 04:23 AM
#4
Thread Starter
Addicted Member
Re: When is a date not a date?
It's daft because it guesses at the format.
I want to pass it a string I know to be in the format DD/MM/YY
so, 59/12/08 is obviously not a valid date.
Nevermind, I'll knock something up myself...
All dates are going to be in this centaury so Ill just prepend "20" to the year field
Another light-hearted post from Guru 
-
Mar 21st, 2007, 06:10 AM
#5
Re: When is a date not a date?
 Originally Posted by Guru
I want to pass it a string I know to be in the format DD/MM/YY
so, 59/12/08 is obviously not a valid date.
But, it is a valid date format and, as gavio has intimated, that is all IsDate will confirm (or deny).
-
Mar 21st, 2007, 09:49 AM
#6
Re: When is a date not a date?
Type this in some sub in VB:
Code:
Dim d As Date
d = #59/12/08#
and move the cursor off the "d =" line. That's why 59/12/08 is a valid date.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|