Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Weekday names (XP)

    I may be missing something- but is ther an easy way to get the weekday name (not just number) from the weekday function? If not did is there a code snippet floating around or should I write it myself?
    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Weekday names (XP)

    No, but you can get the weekday name from the date (i.e. the same date you use as input to WeekDay):
    <UL><LI>For display in a query or control, you can set the Format property of the field or control to dddd.
    <LI>Or you can use the expression Format(DateField_or_Expression, "dddd"), where DateField_or_Expression is the name of the date field, or the expression you want to know the weekday name for. For instance:
    MsgBox "This began on " & Format([StartDate], "dddd")[/list]In both cases
    d = number of day in month 1...31
    dd = number of day in month with leading zero 01...31
    ddd = abbreviated name of day Sun...Sat
    dddd = full name of day Sunday...Saturday

  3. #3
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Weekday names (XP)

    You can use the format function on the date and use ddd as the short days name (eg. Mon) or dddd as the whole days name.
    eg. Format(YourDate,"dddd")

    HTH
    Pat <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  4. #4
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Weekday names (XP)

    If using A2K or later you can use the WeekdayName function, introduced in VB/VBA 6.0, to return a text string representing the day of week. You have to provide this function the numerical day of week as required argument, and can specify whether or not to abbreviate name using optional Abbreviate argument. To obtain the numerical day of week for a specified date, use the Weekday function. Both functions allow you to specify the first day of week using optional firstdayofweek argument; if omitted the default vbSunday is assumed. Example of use:

    ? Weekday(Date(),vbSunday)
    3
    ? WeekdayName(Weekday(Date(),vbSunday),True,vbSunday )
    Tue
    ? WeekdayName(Weekday(Date(),vbSunday),False,vbSunda y)
    Tuesday

    If specifying first day of week other than Sunday, be sure to do so consistently. Example:

    ? Weekday(Date(),vbTuesday)
    1
    ? WeekdayName(Weekday(Date(),vbTuesday),True,vbTuesd ay)
    Tue

    Using the Format function as suggested may be simpler in many cases.

    HTH

  5. #5
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Weekday names (XP)

    thanks to everyone.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •