WEEK( ) Function

Returns a number representing the week of the year from a Date or DateTime expression.

WEEK(dExpression | tExpression [, nFirstWeek] [, nFirstDayOfWeek])

Return Values

Numeric

Parameters

  • dExpression | tExpression
    Specifies the Date or DateTime expression for which WEEK( ) returns the week of the year.

    If you omit the optional nFirstWeek and nFirstDayOfWeek arguments, WEEK( ) uses Sunday as the first day of the week.

  • nFirstWeek
    Specifies the requirements for the first week of the year. nFirstWeek may be one of the following values.

    nFirstWeek Description
    0 WEEK( ) returns whatever week is currently selected in the First Week of Year list box on the Regional tab in the Options dialog box.
    1 First week contains January 1st. This is the default when you omit nFirstWeek.
    2 The larger half (four days) of the first week is in the current year.
    3 First week has seven days.
  • nFirstDayOfWeek
    Specifies the first day of the week. nFirstDayOfWeek may be one of the following values.

    nFirstDayOfWeek Description
    0 WEEK( ) returns whatever day is currently selected in the Week Starts on list box on the Regional tab in the Options dialog box.
    1 Sunday. This is the default when you omit nFirstDayOfWeek, and is the first day of the week used in earlier FoxPro versions.
    2 Monday
    3 Tuesday
    4 Wednesday
    5 Thursday
    6 Friday
    7 Saturday

Remarks

WEEK( ) returns a number from 1 to 53 that represents the week of the year. For example, WEEK( ) returns 1 for the first week of the year, 2 for the second week of the year, and so on. Note that a week can be split between years — the first week of the year can be in the current year and the previous year.

Example

The following example displays the week of the year for today's date and for a specific date.

CLEAR
? WEEK(DATE( ))
? WEEK({^1998-02-16})  && Displays 8

See Also

CDOW( ) | DAY( ) | DOW( ) | SET FDOW | SET FWEEK | SYS( ) Functions Overview