Results 1 to 7 of 7

Thread: Weekday

  1. #1

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Whats the code behind the weekday function? i need a simple fast algoritm that calculates what day it is
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  2. #2
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    258
    Have a look

    WeekdayName(weekday, abbreviate, firstdayofweek)

    The WeekdayName function syntax has these parts:

    Part Description
    weekday Required. The numeric designation for the day of
    the week. Numeric value of each day depends on setting of the firstdayofweek setting.

    abbreviate Optional. Boolean value that indicates if the weekday name is to be abbreviated. If omitted, the default is False, which means that the weekday name is not
    abbreviated.
    firstdayofweek Optional. Numeric value indicating the first
    day of the week. See Settings section for values.

    Settings

    The firstdayofweek argument can have the following values:

    Constant Value Description
    vbUseSystem 0 Use National Language Support (NLS) API setting.
    vbSunday 1 Sunday (default)
    vbMonday 2 Monday
    vbTuesday 3 Tuesday
    vbWednesday 4 Wednesday
    vbThursday 5 Thursday
    vbFriday 6 Friday
    vbSaturday 7 Saturday



    []P
    Visual Basic 6 SP4 on win98se

    QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!

  3. #3

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Eh, nope that's not what i need. I need to get the weekday from a date, without using a vb function, and it could return an index as well...
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    OK, here's my chance to help a guru! Try this, kedaman:

    Code:
    Function DayOfWeek(lngYear As Long, lngMonth As Long, lngDay As Long) As Long
    
    ' sample call: lngMyDOW = DayOfWeek(2000, 11, 12)
    ' the value returned will be from 0 to 6, which is Sunday to Saturday
    
    If lngMonth < 3 Then
          lngYear = lngYear - 1
          lngMonth = lngMonth + 12
    End If
    DayOfWeek = (lngDay + (153 * lngMonth - 457) \ 5 + 365 * lngYear + lngYear \ 4 - lngYear \ 100 + lngYear \ 400 + 2) Mod 7
    
    End Function
    The source for this came from the following link:
    http://www.capecod.net/~pbaum/date/date0.htm

    "It's cold gin time again ..."

    Check out my website here.

  5. #5

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Thanks! that exactly what i needed
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  7. #7
    Lively Member
    Join Date
    Aug 2002
    Location
    Tokyo, Japan
    Posts
    72
    Hey VB Gurus Please help me !

    I want to send Month and Year as parameters to Crystal Report. And want to display all dates and days in that month. For this purpose I have created labels from 1 to 31. But how to send parameters to Crystal Report and how to figure out Days for each date ???
    Everybody is always learning something new !

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