[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

CDate() function

Posted on 2004-04-20
3
Medium Priority
?
1,471 Views
Last Modified: 2013-12-26
Does anyone know why CDate(05/08/0001) is returning me 05/08/2001...And the IsDate function returns this as a valid date as well...I need a function that will return false, because this is not a valid date, or at least I dont think it is....
0
Comment
Question by:BigBadBarnes
3 Comments
 
LVL 9

Expert Comment

by:dancebert
ID: 10872957
To answer your second question, 05/08/0001 is a valid date: May eighth in the year one.
0
 
LVL 39

Accepted Solution

by:
appari earned 375 total points
ID: 10874810

In Microsoft Windows, the range of valid dates is January 1, 100 A.D. through December 31, 9999 A.D

and the years less than 100 are translated to a year with a prefix 19 or 20 based on your regional settings. in your systems regional settings if you see the date settings tab you can see how to interpret 2 digit years.

all date functions see if the string can be converted to a valid date or not. so IsDate function returns true for 05/08/0001 becoz its converting the date to 05/08/2001

if you check cdate("05/08/0031") it reutrns you 05/08/1931.
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 10875283
What format of date are you using ? American or european layout ? (so mm/dd/yyyy or dd/mm/yyyy)
For example:
'if 2/12/99 is 2nd December or 12th Febuary if you don't know which system your machine is using

It will return both valid.
Suppose you have on  your system the american format, then 12/13/2004 will be valid, but 13/12/2004 will be invalid (while you can suppose that it's the other way).

You can also format your date and then validate it with isDate

Here you can find a function to see if a date string is valid using regional date settings
http://www.vb-helper.com/howto_validate_date_international.html
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question