Date Function

Description

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

Syntax

Date

Remarks

To set the system date, use the Date statement.

See Also

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 an expression containing the Date function. This expression will vary according to the format you have chosen to display the date. This 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.

Dim MyDate
MyDate = Date    ' MyDate contains the current system date.
Example (Microsoft Access)

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()