Weekday Function

Named Arguments

Yes

Syntax

Weekday(date, [firstdayofweek])


date

Use: Required

Data Type: Variant

Any valid date expression.


firstdayofweek

Use: Optional

Data Type: Integer

Constant value specifying the first day of the week.

Return Value

A Variant of subtype Integer.

Description

Determines the day of the week of a given date.

Rules at a Glance

  • The following intrinsic constants determine the value returned by the Weekday function:

    Constant Return Value Day Represented
    vbSunday 1 Sunday
    vbMonday 2 Monday
    vbTuesday 3 Tuesday
    vbWednesday 4 Wednesday
    vbThursday 5 Thursday
    vbFriday 6 Friday
    vbSaturday 7 Saturday

  • If date is Null, the Weekday function also returns Null.

  • The following table describes the possible settings for the firstdayofweek argument:

    Constant Value Description
    vbUseSystem

    0 Use the NLS API setting
    vbSunday

    1 Sunday (default)
    vbMonday

    2 Monday
    vbTuesday

    3 Tuesday
    vbWednesday

    4 Wednesday
    vbThursday

    5 Thursday
    vbFriday

    6 Friday
    vbSaturday

    7 Saturday

Programming Tips and Gotchas

  • If you specify a firstdayofweek argument, the function returns the day of the week relative to firstdayofweek. For instance, if you set the value of firstdayofweek to vbMonday (2), indicating that Monday is the first day of the week, and attempt to determine the day of the week on which October 1, 1996, falls, the function returns a 2. That's because October 1, 1996, is a Tuesday, the second day of a week whose first day is Monday.

  • The fact that the function's return value is relative to firstdayofweek makes using the day of the week constants to interpret the function's return value confusing, to say the least. If we use our October 1, 1996, example once again, the following expression evaluates to True if the day of the week is Tuesday:

    If vbMonday = WeekDay(CDate("10/1/96"), vbMonday) Then

See Also

DatePart Function, Day Function, Month Function, Year Function
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.3.43