The following table lists examples of expressions that use the DatePart function to return a portion of a date or time value.
You can use these expressions in calculated controls (calculated control: A control that is used on a form, report, or data access page to display the result of an expression. The result is recalculated each time there is a change in any of the values on which the expression is based.) on forms, reports, and data access pages (data access page: A Web page, published from Access, that has a connection to a database. In a data access page, you can view, add to, edit, and manipulate the data stored in the database. A page can also include data from other sources, such as Excel.).
||Displays the four-digit year of the value of the OrderDate field.
||Displays the quarter the given date falls in. This expression returns 4.
||Displays the hour part of the current date. The expression returns 14 if the current time is 2:08 PM.
||Displays the day part of the current date. The expression returns 14 if the current date is 11/14/2003.
You can use these expressions in a calculated field in a query.
Tip Expression Builder in Access 2010 has IntelliSense, which shows you what arguments your expression requires! Read an article or try Office 2010.
|YearHired: DatePart("yyyy", [HireDate])
||Displays in the YearHired field the year each employee was hired.
|MonthNo: DatePart("M", [OrderDate])
||Displays in the MonthNo field the number of the month.