Date question: How can I get a list of the date of every Friday?

Discussion in 'ASP General' started by michaaal, Oct 4, 2004.

  1. michaaal

    michaaal Guest

    How can I get a list of the date of every friday of the year?

    I realize this code is wrong, but maybe you'll see what I am after...

    Sub GetFridayList()
    For x = 1 to len(Date(2004))
    if Date(2004,x)="Friday" then msgbox (Date2004)
    Next
    End Sub
    michaaal, Oct 4, 2004
    #1
    1. Advertising

  2. There is the Weekday function in VBScript that may work for you.
    http://msdn.microsoft.com/library/en-us/script56/html/vsfctweekday.asp

    If you do not already have the WSH Scripting Documentation downloaded and
    installed, I strongly recommend that you do.
    http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9

    Ray at home

    "michaaal" <> wrote in message
    news:O2%...
    > How can I get a list of the date of every friday of the year?
    >
    > I realize this code is wrong, but maybe you'll see what I am after...
    >
    > Sub GetFridayList()
    > For x = 1 to len(Date(2004))
    > if Date(2004,x)="Friday" then msgbox (Date2004)
    > Next
    > End Sub
    >
    >
    Ray Costanzo [MVP], Oct 4, 2004
    #2
    1. Advertising

  3. michaaal

    dlbjr Guest

    Function GetFridays(intYear)
    Dim ArDates(53)
    intMax = -1
    strStart = DateSerial(intYear,1,1)
    strEnd = DateSerial(intYear,12,31)
    intDay = DatePart("w",strStart)
    If intDay < 5 Then
    strStart = DateAdd("d", 5-intDay,strStart)
    End If
    If intDay > 5 Then
    strStart = DateAdd("d", (7-intDay) + 5,strStart)
    End If
    For I = 0 To 53
    strStart = DateAdd("ww",1,strStart)
    If CDate(strStart) =< CDate(strEnd) Then
    ArDates(i) = strStart
    intMax = intMax + 1
    End If
    Next
    GetFridays = Join(ArDates,",")
    GetFridays = Left(GetFridays,Len(GetFridays) - (53 - intMax))
    End Function

    --
    'dlbjr
    'Pleading sagacious indoctrination!
    dlbjr, Oct 4, 2004
    #3
  4. Essentially, get the first Friday, then add 7 to the date until the end of
    the year

    <%
    Dim firstDay
    Dim firstWeekDay
    Dim firstFriday
    Dim everyFriday


    firstDay = DateSerial(1, 1, 2004)

    ' Assuming Sunday is the first day of the week
    firstWeekDay = WeekDay(firstDay, vbSunday)

    ' Compute the date of the first Friday
    If vbFriday >= firstWeekDay Then
    firstFriday = firstDay + (vbFriday - firstWeekDay)
    Else
    firstFriday = firstDay + (vbFriday - firstWeekDay) + 7
    End If

    everyFriday = firstFriday

    ' Now that you have the first Friday, loop until you hit the end of the year
    Do While Year(everyFriday) = 2004
    Response.Write("<br>" & everyFriday)
    everyFriday = everyFriday + 7
    Loop

    %>
    --
    Manohar Kamath
    Editor, .netWire
    www.dotnetwire.com


    "michaaal" <> wrote in message
    news:O2%...
    > How can I get a list of the date of every friday of the year?
    >
    > I realize this code is wrong, but maybe you'll see what I am after...
    >
    > Sub GetFridayList()
    > For x = 1 to len(Date(2004))
    > if Date(2004,x)="Friday" then msgbox (Date2004)
    > Next
    > End Sub
    >
    >
    Manohar Kamath, Oct 4, 2004
    #4
  5. michaaal

    michaaal Guest

    Manohar Kamath" <> wrote in message
    news:...
    > Essentially, get the first Friday, then add 7 to the date until the end of
    > the year
    >
    > <%
    > Dim firstDay
    > Dim firstWeekDay
    > Dim firstFriday
    > Dim everyFriday
    >
    >
    > firstDay = DateSerial(1, 1, 2004)
    >
    > ' Assuming Sunday is the first day of the week
    > firstWeekDay = WeekDay(firstDay, vbSunday)
    >
    > ' Compute the date of the first Friday
    > If vbFriday >= firstWeekDay Then
    > firstFriday = firstDay + (vbFriday - firstWeekDay)
    > Else
    > firstFriday = firstDay + (vbFriday - firstWeekDay) + 7
    > End If
    >
    > everyFriday = firstFriday
    >
    > ' Now that you have the first Friday, loop until you hit the end of the

    year
    > Do While Year(everyFriday) = 2004
    > Response.Write("<br>" & everyFriday)
    > everyFriday = everyFriday + 7
    > Loop
    >
    > %>
    > --
    > Manohar Kamath
    > Editor, .netWire
    > www.dotnetwire.com
    >
    >
    > "michaaal" <> wrote in message
    > news:O2%...
    > > How can I get a list of the date of every friday of the year?
    > >
    > > I realize this code is wrong, but maybe you'll see what I am after...
    > >
    > > Sub GetFridayList()
    > > For x = 1 to len(Date(2004))
    > > if Date(2004,x)="Friday" then msgbox (Date2004)
    > > Next
    > > End Sub
    > >
    > >

    >
    >



    You guys are the best. Thank you for the code.
    michaaal, Oct 4, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SXJ3YW5zeWFo?=
    Replies:
    4
    Views:
    2,450
    =?Utf-8?B?SXJ3YW5zeWFo?=
    Oct 30, 2007
  2. Chumley the Walrus
    Replies:
    3
    Views:
    139
    Chumley the Walrus
    Aug 27, 2004
  3. Kero
    Replies:
    10
    Views:
    224
    James Britt
    Oct 7, 2004
  4. Kero
    Replies:
    9
    Views:
    135
    Jonas Hartmann
    Oct 13, 2005
  5. CK

    Determine next Friday's date?

    CK, Feb 23, 2006, in forum: Javascript
    Replies:
    12
    Views:
    174
Loading...

Share This Page