DatePart Function

See AlsovbfctDatePartSee                 ExamplevbfctDatePartEx>Low


Returns a specified part of a given date.


DatePart( interval, date )


The DatePart function uses the following parts:

Part                 Description


interval             String expression1330R89 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 KitGUH5X7 provides tools to help you write setup programs that install your applications.