Access: DateSerial Function

In Access, the DateSerial function returns the date for a specific year, month, and day.

The syntax for the DateSerial function is:

DateSerial ( year, month, day )

The DateSerial function returns a date that is stored internally as a double-precision number. This number represents a date from January 1, 100 through December 31, 9999. If the date specified by the three arguments, either directly or by expression, falls outside the acceptable range of dates, an error occurs.

year is a number between 100  and 9999, inclusive, that represents the year value of the date.

month is a number between 1 and 12, inclusive, that represents the month value of the date.

day is a number between 1 and 31, inclusive, that represents the day value of the date.

Examples

DateSerial (2004,3,24 )         returns 03/24/2004 
DateSerial(1998,7-5,17 )        returns 02/17/1998
DateSerial(2000,5,24-9 )        returns 05/15/200

VBA Code

Dim MyDate As Date
MyDate = DateSerial(2005,3,14)

This example uses the DateSerial function to return the date for the specified year, month, and day. Now the MyDate variable would contain the value of 3/14/2005.

SQL query

You can also use the DateSerial function in a query.

SELECT DateSerial(2005,7,21) AS Expr1 
FROM Orders
admin

admin

Leave a Reply

Your email address will not be published.