Date Function

Description

Returns the current system date.

Syntax

Date

Remarks

To set the system date, use the Date statement.

See Also

CDate Function, Date Statement, Format Function, Now Function, Time Function, Time Statement.

Specifics (Microsoft Access)

You can insert the current date on a form or report by clicking Date And Time on the Insert menu. This command creates a text box on a form or report and sets the ControlSource property of the text box to the expression =Date(). The command is available only in form Design view and report Design view.

You can also use the Date function in a query expression or in a macro. However, you must include the parentheses after the function when you use it anywhere other than a Visual Basic module, as in the expression Date().

Example

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


MyDate = Date                ' MyDate contains the current system date.

You can use the Date function in a calculated control by setting the ControlSource property of the control as in the following example.


= Date()

You can also use the Date function to set criteria for a query. For example, if you have an Orders table that contains an OrderDate field, you can create a query on the Orders table to return all records that have an OrderDate between 4-1-95 and today’s date. Enter the following in the Criteria cell under the OrderDate field.


Between #4-1-95# and Date()