+ Reply to Thread
Results 1 to 5 of 5

Weekday() result differs from one computer to another ???

  1. #1
    bobm
    Guest

    Weekday() result differs from one computer to another ???

    Hello,

    Don't why I get different a result from one computer to another using the
    Weekday and Weekday name functions. I am specifying Sunday as weekday 1 not
    using the default and still get different results.

    The code I am using is...

    WeekdayName(Weekday(StartDate, vbSunday), vbSunday)

    On one computer which is correct I get...

    1 Sun
    2 Mon
    3 Tue... etc

    On the other I get...
    1 Mon
    2 Tue
    3 Wed... etc

    The worksheet function works correctly on both but not VBA. Any help
    appreciated.

    bobm












  2. #2
    K Dales
    Guest

    RE: Weekday() result differs from one computer to another ???

    The worksheet function has 2 arguments, the VBA function has 3:
    WeekdayName(weekday, abbreviate, firstdayofweek)
    So where you are using vbSunday it is interpreting it as the 'abbreviate'
    parameter = 1, True; and because you don't specify the 'firstdayofweek' it
    takes the default value, which happens to be vbUseSystem - so if the system
    settings vary on the two computers, the result is different.

    If this is what is happening, you should be able to fix it by changing the
    VBA function call to be
    WeekdayName(Weekday(StartDate, vbSunday), True, vbSunday)

    --
    - K Dales


    "bobm" wrote:

    > Hello,
    >
    > Don't why I get different a result from one computer to another using the
    > Weekday and Weekday name functions. I am specifying Sunday as weekday 1 not
    > using the default and still get different results.
    >
    > The code I am using is...
    >
    > WeekdayName(Weekday(StartDate, vbSunday), vbSunday)
    >
    > On one computer which is correct I get...
    >
    > 1 Sun
    > 2 Mon
    > 3 Tue... etc
    >
    > On the other I get...
    > 1 Mon
    > 2 Tue
    > 3 Wed... etc
    >
    > The worksheet function works correctly on both but not VBA. Any help
    > appreciated.
    >
    > bobm
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >


  3. #3
    okaizawa
    Guest

    Re: Weekday() result differs from one computer to another ???

    Hi,

    is the contents of the variable 'StartDate' certainly the same?
    try something like this:

    Sub Test()
    Dim StartDate As Date
    StartDate = Date
    MsgBox StartDate
    MsgBox WeekdayName(Weekday(StartDate, vbSunday), True, vbSunday)
    End Sub


    Format(StartDate, "ddd") also would work.

    http://msdn.microsoft.com/library/en...ateformats.asp
    http://msdn.microsoft.com/library/en...eekdayName.asp

    --
    HTH,

    okaizawa


    bobm wrote:
    > Hello,
    >
    > Don't why I get different a result from one computer to another using the
    > Weekday and Weekday name functions. I am specifying Sunday as weekday 1 not
    > using the default and still get different results.
    >
    > The code I am using is...
    >
    > WeekdayName(Weekday(StartDate, vbSunday), vbSunday)
    >
    > On one computer which is correct I get...
    >
    > 1 Sun
    > 2 Mon
    > 3 Tue... etc
    >
    > On the other I get...
    > 1 Mon
    > 2 Tue
    > 3 Wed... etc
    >
    > The worksheet function works correctly on both but not VBA. Any help
    > appreciated.
    >
    > bobm
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >


  4. #4
    Harald Staff
    Guest

    Re: Weekday() result differs from one computer to another ???

    Hi

    If you just want the day name, use this simple approach instead:
    Format(StartDate, "ddd")
    or
    Format(StartDate, "dddd")

    HTH. Best wishes Harald

    "bobm" <[email protected]> skrev i melding
    news:[email protected]...
    > Hello,
    >
    > Don't why I get different a result from one computer to another using the
    > Weekday and Weekday name functions. I am specifying Sunday as weekday 1

    not
    > using the default and still get different results.
    >
    > The code I am using is...
    >
    > WeekdayName(Weekday(StartDate, vbSunday), vbSunday)
    >
    > On one computer which is correct I get...
    >
    > 1 Sun
    > 2 Mon
    > 3 Tue... etc
    >
    > On the other I get...
    > 1 Mon
    > 2 Tue
    > 3 Wed... etc
    >
    > The worksheet function works correctly on both but not VBA. Any help
    > appreciated.
    >
    > bobm
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >




  5. #5
    bobm
    Guest

    Re: Weekday() result differs from one computer to another ???

    thankyou all. appreciate your help as always...

    bobm

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1