Click or drag to resize

Week Function (DateTime, Long, Long)

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

Namespace:  XSharp.VFP
Assembly:  XSharp.VFP (in XSharp.VFP.dll) Version: 2.19
Syntax
 FUNCTION Week(
	tExpression AS DateTime,
	 nFirstWeek AS LONG,
	 nFirstDayOfWeek AS LONG
) AS LONG
Request Example View Source

Parameters

tExpression
Type: DateTime
Specifies the DateTime expression for which WEEK( ) returns the week of the year.
nFirstWeek
Type: Long
Specifies how the first week should be calculated. Valid values are 1, 2 and 3.
The value 0 which can be set in the Options box in FoxPro is the same as the default value 1. The remarks section has a list of all possible values.
nFirstDayOfWeek
Type: Long
Specifies the first day of the week. Valid values are 1 (Sunday) - 7 (Saturday).
The value 0 which can be set in the Options box in FoxPro is the same as the default value 1. The remarks section has a list of all possible values.

Return Value

Type: Long
Numeric type. Week() returns a number representing the week of the year.
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.

Possible values for nFirstweek are

nFirstweekDescription
0 and 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.

Possible values for nFirstDayOfWeek are

nFirstDayOfWeekDescription
0 and 1 Sunday. This is the default when you omit nFirstDayOfWeek
2 Monday
3 Tuesday
4 Wednesday
5 Thursday
6 Friday
7 Saturday
Examples
X#
1Clear
2? Week(Date( ))
3? Week({^1998-02-16})  // Displays 8
See Also