Results 1 to 3 of 3

Thread: Day of week

  1. #1
    blaidd drwg
    Guest

    Default Day of week

    Is there a better way to get day of the week then:

    Public Function DayOfWeek(ChartID, Record)
    Dim DAYS(7)
    DAYS(0) = "Sunday"
    DAYS(1) = "Monday"
    DAYS(2) = "Tuesday"
    DAYS(3) = "Wednesday"
    DAYS(4) = "Thursday"
    DAYS(5) = "Friday"
    DAYS(6) = "Saturday"

    Dim MT(12)
    MT(0) = 0
    MT(1) = 31
    MT(2) = 59
    MT(3) = 90
    MT(4) = 120
    MT(5) = 151
    MT(6) = 181
    MT(7) = 212
    MT(8) = 243
    MT(9) = 273
    MT(10) = 304
    MT(11) = 334

    Dim y
    Dim m
    Dim d
    Dim r

    y = CINT(GetYear(CLNG(ChartID), CLNG(Record)))
    m = CINT(GetMonth(CLNG(ChartID), CLNG(Record)))
    d = CINT(GetDay(CLNG(ChartID), CLNG(Record)))
    r = 0
    if ((y mod 4 = 0) and (y mod 100 <> 0) and (m > 2)) Then
    r = 1
    End If

    DayOfWeek = CSTR(DAYS(CINT(((y-1)*365 + ((y-1) \ 4) - ((y-1) \ 100) + MT(m-1) + r + d + 5) mod 7)))
    End Function

  2. #2
    Administrator Hassan-HS's Avatar
    Join Date
    Jun 2013
    Posts
    795

    Default

    Hello,


    you can use this Vb-script built-in function

    Code:
    MsgBox WeekdayName(Weekday(GetTime(0,bars(0))))

  3. #3
    blaidd drwg
    Guest

    Default

    gr8 :-)
    thank You.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

Posting Permissions

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