473,320 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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
Jul 19 '05 #1
4 1849
There is the Weekday function in VBScript that may work for you.
http://msdn.microsoft.com/library/en...fctweekday.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/d...6-1C4099D7BBB9

Ray at home

"michaaal" <re******@verizon.net> wrote in message
news:O2****************@TK2MSFTNGP12.phx.gbl...
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

Jul 19 '05 #2
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!
Jul 19 '05 #3
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" <re******@verizon.net> wrote in message
news:O2****************@TK2MSFTNGP12.phx.gbl...
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

Jul 19 '05 #4
Manohar Kamath" <mk*****@TAKETHISOUTkamath.com> wrote in message
news:Oy**************@TK2MSFTNGP10.phx.gbl...
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" <re******@verizon.net> wrote in message
news:O2****************@TK2MSFTNGP12.phx.gbl...
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.

Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Shlomi Schwartz | last post by:
Hi all, Why do I get the folowing date when creating it like so: var d = new Date(2003,9,2); Wed Oct 1 23:00:00 UTC+0200 2003 Isent it soposed to be:
11
by: CK | last post by:
Hi All, Looking for a simple function to return the date for the follwing Friday. I send out emails from time to time and I would like a function that dynamically returns the date for the...
1
by: assgar | last post by:
Hi I need help. I know what I want to accomplish, but I do not know how to do it. WHAT I NEED HELP ACCOMPLISHING: How to do I insert data into a table for a date range of...
0
by: gpspocket | last post by:
help me -CURSOR backward insert from End Date > to Start Date how to insert dates from end to start like this SELECT 111111,1,CONVERT(DATETIME, '17/03/2008', 103), CONVERT(DATETIME,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.