Weekday (function)

Syntax

Weekday(date)

Description

Returns an Integer value representing the day of the week given by date. Sunday is 1, Monday is 2, and so on.

The date parameter is any expression representing a valid date.

Example

This example gets a date in an input box and displays the day of the week and its name for the date entered.

Sub Main()
  Dim a$(7)
  a$(1) = "Sunday"
  a$(2) = "Monday"
  a$(3) = "Tuesday"
  a$(4) = "Wednesday"
  a$(5) = "Thursday"
  a$(6) = "Friday"
  a$(7) = "Saturday"

Reprompt:
  bd = InputBox("Please enter your birthday.","Enter Birthday")
  If Not(IsDate(bd)) Then Goto Reprompt

  dt = DateValue(bd)
  dw = WeekDay(dt)
  Msgbox "You were born on day " & dw & ", which was a " & a$(dw)
End Sub

See Also

Day (function);Minute (function); Second (function); Month (function); Year (function); Hour (function); DatePart (function).

More information

W