473,763 Members | 3,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Find Every Other Friday

Has anyone written any code to find the date of every other Friday of the year?
Is there an easy way of doing this?
Nov 21 '05 #1
3 3048
Peter,

Do you mean something as this?
\\\
If Now.DayOfWeek = DayOfWeek.Frida y Then
MessageBox.Show ("Today it is Friday")
End If
///

I hope this helps?

Cor
Has anyone written any code to find the date of every other Friday of the year? Is there an easy way of doing this?

Nov 21 '05 #2
Peter,
Do you want to start with the first or second Friday of the year?

Here is a routine that will print every other Friday starting with the first
Friday after the start date, going until the last Friday before the end
date.

Private Shared Sub PrintEveryOther Week(ByVal startDate As DateTime,
ByVal endDate As DateTime)
Dim friday As DateTime = startDate.AddDa ys(DayOfWeek.Fr iday -
startDate.DayOf Week)

Do Until friday > endDate
Debug.WriteLine (friday, "friday")
friday = friday.AddDays( 14)
Loop
End Sub

Public Shared Sub Main()
PrintEveryOther Week(Today, Today.AddYears( 1))
End Sub

Just replace the Debug.WriteLine with the logic that you need. You can
change the range by setting the start date & end date as appropriate, for
example:

PrintEveryOther Week(New DateTime(2004, 1, 1), New DateTime(2005, 1,
1))

Note you need to decide if the end date needs to be inclusive or exclusive.
I made it exclusive in the above example.

Hope this helps
Jay

"Peter" <pe***@mclinn.c om> wrote in message
news:dc******** *************** ***@posting.goo gle.com...
Has anyone written any code to find the date of every other Friday of the year? Is there an easy way of doing this?

Nov 21 '05 #3
Hi,
Not sure if you are looking for something like this:

Dim t As DateTime = New DateTime (2004, 1, 2) 'First Friday of the year
While (t.Year = 2004)
Console.WriteLi ne (t)
t.AddDays (14) 'Every other Friday
End While

"Peter" <pe***@mclinn.c om> wrote in message
news:dc******** *************** ***@posting.goo gle.com...
Has anyone written any code to find the date of every other Friday of the
year?
Is there an easy way of doing this?
Nov 21 '05 #4

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

Similar topics

11
5741
by: Matt | last post by:
My ASP page allows the user select the date, and it will display the report during that week of that date. My question is when the program query database, I need to know the beginning date and ending date of that week. Any ideas??
4
1873
by: michaaal | last post by:
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
20
5042
by: Laguna | last post by:
Hi Gurus, I want to find the expiration date of stock options (3rd Friday of the month) for an any give month and year. I have tried a few tricks with the functions provided by the built-in module time, but the problem was that the 9 element tuple need to be populated correctly. Can anyone help me out on this one? Thanks a bunch, Laguna
11
15979
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 follwing Friday. So no matter what day I send it, it will dynamically calculate Friday's date. Also if I am sending it on a Friday, I would like to return the current date, Saturday and later will return next Friday's date. Thanks for any advice. ...
5
3721
by: vj | last post by:
I'm doing: a = now() delta = ReltaiveDateTime(days=+6, weekday(mx.DateTime.Friday, 0)) Next Friday: a+delta a: march 23 a+delta: Gives me March 31st and not March 24th Any ideas?
1
1178
by: ibiza | last post by:
Hi all, I need to find a specific, for example the third friday of a given month/year. How to do that? thanks :)
10
32829
by: sherifffruitfly | last post by:
Hi all, This is how I'm currently getting Friday of last week. It strikes me as cumbersome. Is there a slicker/more elegant way? Thanks for any ideas, cdj
1
2195
by: Matt | last post by:
I have table that has the following fields: JobNumber WeekEndingDate ReportRequired_01 ReportRequired_02 every Friday morning the weekending date changes. I need to automatically generate a new record for each record that has a job number and weekending date for the new weekending date.
3
6137
by: ats | last post by:
Does anybody have any sample code for calculating the date for teh last Friday in each month. TIA -- ats@jbex When an old lady got hit by a truck I saw the wicked gleam in your eyes
0
9563
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10145
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9822
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7366
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.