Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Contact us
Hide Buttons

VBA-Excel: Date-Time Functions – WeekDay() and WeekDayName()

Week­Day()

Description:

The Week­Day func­tion takes Date as a para­me­ter and returns a num­ber between 1 and 7, that is the week day of the date provided.

Format:

Week­Day (str­Date [Firstdayofweek])

Arguments:
  • str­Date
    • Manda­tory
    • Type: Date
    • Date, whose Week Date need to be calculated.

  • First­day­ofweek
    • Optional
    • Type: Numeric
    • Spec­i­fies the first day of the week
Con­stant Value Descrip­tion
vbUs­eSys­tem 0 Use the NLS API setting.
vbSun­day 1 Sun­day (default)
vbMon­day 2 Mon­day
vbTues­day 3 Tues­day
vbWednes­day 4 Wednes­day
vbThurs­day 5 Thurs­day
vbFri­day 6 Fri­day
vbSat­ur­day 7 Sat­ur­day

Exam­ple:

Function FnWeekDay()

   Dim strDate

   strDate = "15-July-2013"    

   MsgBox "WeekDay of the " & strDate & " is -> " & Weekday(strDate)    

End Function
WeekDay()

Week­Day()

_________________________________________________________________________________

Week­Day­Name()

Description:

The Week­Day­Name func­tion The takes numeric  value as a para­me­ter and returns a week day Name.

Format:

WeekdayName(intWeekday, blnAb­bre­vi­ate, firstdayofweek)

Arguments:
  • intWeek­Day
    • Manda­tory
    • Type: Numeric
    • Value from 1 to 7, Mon­day to Sun­day, whose Week Day Name need to be cal­cu­lated. Like WeekDayName(1) will return “Monday”
  • blnAb­bre­vi­ate
    • Optional
    • Type: Boolean
    • True value will pro­vide the month name abbre­vi­ated, for exam­ple “Mon­day” will be abbre­vi­ated to “Mon”, and default value is False.
  • First­day­ofweek
    • Optional
    • Type: Numeric
    • Spec­i­fies the first day of the week
Con­stant Value Descrip­tion
vbUs­eSys­tem 0 Use the NLS API setting.
vbSun­day 1 Sun­day (default)
vbMon­day 2 Mon­day
vbTues­day 3 Tues­day
vbWednes­day 4 Wednes­day
vbThurs­day 5 Thurs­day
vbFri­day 6 Fri­day
vbSat­ur­day 7 Sat­ur­day

Exam­ple:

Function FnWeekDayName()

   Dim strDate

   Dim strResult

    strDate = "1-July-2013"

   strResult = "Full WeekDay Name of the " & strDate & " is -> " & WeekdayName(Weekday(strDate)) & vbCrLf

   strResult = strResult & "Abbriviated Week Day Name of the " & strDate & " is -> " & WeekdayName(Weekday(strDate), True)

   MsgBox strResult

End Function
WeekDayName()

Week­Day­Name()

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: