MS Access IsDate() Function
The IsDate()
function in MS Access checks whether a given expression can be interpreted as a valid date. This is a very useful function for data validation, particularly when dealing with data that might contain invalid date formats or non-date values.
IsDate(): Definition and Usage
IsDate()
is used to determine if a value can be converted to a date data type. It's often used to ensure that data entered into a date field conforms to the correct format and to prevent errors caused by invalid dates. The function returns a Boolean value: True
(-1) if the expression is a valid date and False
(0) otherwise.
Syntax
Syntax
IsDate(expression)
Parameter Values
Parameter | Description |
---|---|
expression |
The value or expression you want to check. This can be a string, number, or any other expression that might represent a date. This is required. |
Examples
Testing the Current Date
This example checks if the current date (returned by the Now()
function) is a valid dateāit should be!
Syntax
SELECT IsDate(Now());
Output
True (-1)
Testing Invalid Date Text
This checks if the text string "Hello" can be interpreted as a date (it cannot).
Syntax
SELECT IsDate("Hello");
Output
False (0)
Testing a Valid Date String
This checks a date string in a common format.
Syntax
SELECT IsDate("August 25, 2017");
Output
True (-1)
Testing a Date Literal
Checking a date using Access's date literal notation.
Syntax
SELECT IsDate(#25/8/2017#);
Output
True (-1)