DATEPART Function



Important

The values in this function do not all correspond to the values that you find in Preferences > Formats tab. Explanations for the Interval Value are included in the Comments column.

Function Type

Predefined function

Syntax

DATEPART( <interval>, <dateValue> )

Description

Returns a part of a date based on a specified time interval.

Argument

Description

<interval>

String describing "part" of the time interval to extract from <dateValue>. Shown below is a list of valid time interval parts:

Time Parts

Interval Value

Comments

Year

y

Values returned include a four-digit year (such as 2006).

Quarter

q

Values returned include: 1 - 4.

Month

M

Values returned include: 0 - 11.

Important

For your month numbers to match standard month numbers, you need to add 1 to the values above.

Day of Year

D

Returns the Julian date. Values returned include: 1 - 366.

Day of Week

d

Values returned include: 1 - 7 (where, in the U.S.,1 equals Sunday and 7 equals Saturday)

Week # of Month

E

Values returned include: 0 - 5 (where 0 is an incomplete week at the beginning of the month, 1 is the earliest complete week, and five is the latest week)

Week of Year

w


Hour in Day

H

Values returned include: 0 - 23.

Minute in Hour

m

Values returned include: 0 - 59.

Second in Minute

s

Values returned include: 0 - 59.

<dateValue>

Date type representing the whole date from which the specified part is to be extracted.

Returns

Integer

Example

This example returns the number of the week of the month in the Date1 source field.

DATEPART("E", Source.Table.Date1)


 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*