Access: DateValue Function

In Access, the DateValue function returns the date represented by the date of a String argument.

The syntax for the DateValue function is:

DateValue ( string )

The argument string is a String representing a date from January 1, 100 through December 31, 9999. It can include a time component, if desired. If string includes only numbers, DateValue recognizes the order for month, day, and year according to the Date Format setting in the International section of the Microsoft Windows Control Panel. If the year part of string is omitted, DateValue uses the current year from your computer’s system date. If string includes time information, DateValue does not return it.

Examples

DateValue("May 5")            returns 05/05/2005 
DateValue ("May 5,1985")      returns 05/05/1985
DateValue ("11/22/93")        returns 11/22/1993

VBA Code

Dim MyDate As String 
MyDate = DateValue("October 10, 2005")

This example uses the DateValue function to convert a string to a date. Now the MyDate variable would contain the value of 10/10/2005.

SQL query

You can also use the DateValue function in a query.

SELECT DateValue('May 25,2004') AS Expr1 
FROM Orders
admin

admin

Leave a Reply

Your email address will not be published.