Applies ToAccess for Microsoft 365 Access 2024 Access 2021 Access 2019 Access 2016

Returns a Variant (Date) containing the current system date.

Syntax

Date

Remarks

To set the system date, use the Date statement.

If you use the Date function with a Gregorian calendar, the behavior of Date$ is unchanged by the Calendar property setting. If the calendar is Hijri, Date$ returns a 10-character string of the form mm-dd-yyyy, where mm (01-12), dd (01-30) and yyyy (1400-1523) are the Hijri month, day and year. The equivalent Gregorian range is Jan 1, 1980 through Dec 31, 2099.

Query examples

Expression

Results

SELECT Date() AS Expr1 FROM ProductSales GROUP BY Date();

Returns the current system "date" for in short date format. Result: "dd/mm/yyyy".

SELECT Date()-[DateofSale] AS DaysSinceSale FROM ProductSales;

Returns the difference between current system "Date" and date values of the field "DateofSale" as number and displays the results in column "DaySinceSale".

VBA examples

Use Date in an expression     You can use the Date function wherever you can use expressions. For example, you can set the Control Source property of a text box on a form as follows:

=Date()

When the form is open in Form view, the text box displays the current system date.

Use the Date function in VBA code    

Note: Examples that follow demonstrate the use of this function in a Visual Basic for Applications (VBA) module. For more information about working with VBA, select Developer Reference in the drop-down list next to Search and enter one or more terms in the search box.

This example uses the Date function to return the current system date.

Dim MyDateMyDate = Date    ' MyDate contains the current system date.

Choose the right date function

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.