WEEK( ) Function Example See AlsoReturns a number representing the week of the year from a Date or DateTime expression.SyntaxWEEK(dExpression | tExpression [, nFirstWeek] [, nFirstDayOfWeek])ReturnsNumericArgumentsdExpression | tExpressionSpecifies 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.nFirstWeekSpecifies 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 International 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. nFirstDayOfWeekSpecifies 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 International 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 ResWEEK( ) 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.WEEK( ) Function ExampleThe 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
weeks=DateDiff("d", #1/1/2003#, Date) \ 7 + IIf(DateDiff("d", #1/1/2003#, Date) Mod 7 <> 0, 0, 1)
或
datediff("ww",format(date,"yyyy-01-01") ,date) + 1
Example See AlsoReturns a number representing the week of the year from a Date or DateTime expression.SyntaxWEEK(dExpression | tExpression [, nFirstWeek] [, nFirstDayOfWeek])ReturnsNumericArgumentsdExpression | tExpressionSpecifies 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.nFirstWeekSpecifies 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 International 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.
nFirstDayOfWeekSpecifies 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 International 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
ResWEEK( ) 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.WEEK( ) Function ExampleThe 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
返回或设置一个值,指出当前的星期序号。语法object.Week [= number]Week 属性的语法包括以下部分:部分 描述
Object 一个对象表达式,其值为“应用于”列表中的对象。
Number 一个数值表达式,其值为一个表示星期序号的整数。
说明Week 属性可以设置为从1 到 52 的任意整数。