See Also Example
Description
Returns a specified part of a given date.
Syntax
DatePart( interval, date )
Remarks
The DatePart function uses the following parts:
Part Description
interval String expression that is the interval of time you want to return.
date Date that you want to inspect.
You can use the DatePart function to inspect a date and return a specific interval of time. For example, you might use DatePart to calculate the day of the week or the current hour.
The following table lists the valid time periods and their interval values. These intervals are also used by the Format function.
Time period Interval
Year yyyy
Quarter q
Month m
Day of Year y
Day d
Weekday w
Week ww
Hour h
Minute n
Second s
For Weekday, Sunday = 1, Monday = 2, and so on.
Distribution Note When you create and distribute applications that use this function in your code (not necessary if included only in SQL statements for your database), you should install the file MSAFINX.DLL in the customer's Microsoft Windows \SYSTEM directory. The Visual Basic Setup Kit provides tools to help you write setup programs that install your applications.