Results 1 to 4 of 4

Thread: [RESOLVED] WeekdayName -> Date.DayOfWeek vs Weekday() different

  1. #1

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Resolved [RESOLVED] WeekdayName -> Date.DayOfWeek vs Weekday() different

    Dt = 7/16/2013 Tuesday....

    Dim DN As String = WeekdayName(Weekday(dT))
    DN = Tuesday

    Dim DN As String = WeekdayName(dT.DayOfWeek)
    DN=Monday

    Any clue why?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  2. #2
    Addicted Member cellus205's Avatar
    Join Date
    Dec 2010
    Location
    San Antonio, TX
    Posts
    237

    Re: WeekdayName -> Date.DayOfWeek vs Weekday() different

    dT.DayOfWeek should already return the weekday name, but since you are using it as a parameter it passes the integer value to WeekdayName, which has a different set of indexes than DayOfWeek. DayOfWeek integer values are 0 - 6, which represent the days of the week, while WeekdayName is 0 - 7, with 0 being a flag for the system first day of the week.

    http://msdn.microsoft.com/en-us/libr...(v=vs.80).aspx

    http://msdn.microsoft.com/en-us/libr...dayofweek.aspx

    edit: Sorry I read it wrong, it does return an integer, but the indexes are still different. The first example you listed should be the correct way
    Last edited by cellus205; Jul 16th, 2013 at 10:25 AM.

  3. #3

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: WeekdayName -> Date.DayOfWeek vs Weekday() different

    ahhh!!! i missed that!!! DayOfWeek is 0-6

    bingo!

    thank you! was driving me nuts! lol
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  4. #4
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: [RESOLVED] WeekdayName -> Date.DayOfWeek vs Weekday() different

    You do not need to use WeekdayName.

    Code:
            Dim DN As String = Dt.DayOfWeek.ToString
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

Posting Permissions

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



Click Here to Expand Forum to Full Width