• Weekday names (XP)

    Author
    Topic
    #383161

    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

    Viewing 3 reply threads
    Author
    Replies
    • #652513

      No, but you can get the weekday name from the date (i.e. the same date you use as input to WeekDay):

      • For display in a query or control, you can set the Format property of the field or control to dddd.
      • 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
    • #652514

      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 smile

    • #652522

      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,vbSunday)
      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,vbTuesday)
      Tue

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

      HTH

    • #652538

      thanks to everyone.

    Viewing 3 reply threads
    Reply To: Weekday names (XP)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: