| | |
how to count how many Fridays in amonth
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2007
Posts: 18
Reputation:
Solved Threads: 0
C# Syntax (Toggle Plain Text)
DateTime tempdate = new DateTime(month you want day 1); int fridays = 0; while(tempdate == month you want){ if(tempdate.day = friday){ fridays ++; } tempdate.addday(); }
Last edited by jonesc5; Jan 26th, 2008 at 12:46 pm. Reason: typo
•
•
Join Date: Nov 2006
Posts: 436
Reputation:
Solved Threads: 72
Yes, I used Visual Studio 2005 to create the project.
It is basically what someone else posted later on:
A combobox with all the months (cbMonth), and numericupdown (edYear) and a a simple textbox (edFridays), and ofcourse a Go button that calls the code above.
Basically you need to use the DateTime property (DayOfWeeK0 to determine its day, and increment a counter.
Jerry
It is basically what someone else posted later on:
C# Syntax (Toggle Plain Text)
int Fridays = 0; int m_Month = cbMonth.SelectedIndex + 1; int m_Year = Convert.ToInt32(edYear.Value); DateTime dt = new DateTime(m_Year, m_Month, 1); while (dt.Month == m_Month) { if (dt.DayOfWeek == DayOfWeek.Friday) Fridays++; dt = dt.AddDays(1); } edFridays.Text = Fridays.ToString();
A combobox with all the months (cbMonth), and numericupdown (edYear) and a a simple textbox (edFridays), and ofcourse a Go button that calls the code above.
Basically you need to use the DateTime property (DayOfWeeK0 to determine its day, and increment a counter.
Jerry
•
•
Join Date: Dec 2007
Posts: 41
Reputation:
Solved Threads: 0
•
•
•
•
Yes, I used Visual Studio 2005 to create the project.
It is basically what someone else posted later on:
C# Syntax (Toggle Plain Text)
int Fridays = 0; int m_Month = cbMonth.SelectedIndex + 1; int m_Year = Convert.ToInt32(edYear.Value); DateTime dt = new DateTime(m_Year, m_Month, 1); while (dt.Month == m_Month) { if (dt.DayOfWeek == DayOfWeek.Friday) Fridays++; dt = dt.AddDays(1); } edFridays.Text = Fridays.ToString();
A combobox with all the months (cbMonth), and numericupdown (edYear) and a a simple textbox (edFridays), and ofcourse a Go button that calls the code above.
Basically you need to use the DateTime property (DayOfWeeK0 to determine its day, and increment a counter.
Jerry
Thank you very much Jerry for help
•
•
Join Date: Jan 2008
Posts: 2
Reputation:
Solved Threads: 0
•
•
•
•
hi
ineed a help in C# programming language i want to know how to a ccount how many Fridays and Saturdays in specific month
can i do it in C#
With Regards,
DateTime MyDate = DateTime.Now;
MyDate = new DateTime(MyDate.Year, MyDate.Month, 1);
int NoofFridays = 0;
do
{
if (MyDate.DayOfWeek.ToString() == "Friday")
NoofFridays++;
MyDate = MyDate.AddDays(1);
} w
•
•
Join Date: Jan 2008
Posts: 2
Reputation:
Solved Threads: 0
•
•
•
•
hi
ineed a help in C# programming language i want to know how to a ccount how many Fridays and Saturdays in specific month
can i do it in C#
With Regards,
DateTime MyDate = DateTime.Now;
MyDate = new DateTime(MyDate.Year, MyDate.Month, 1);
int NoofFridays = 0;
do
{
if (MyDate.DayOfWeek.ToString() == "Friday")
NoofFridays++;
MyDate = MyDate.AddDays(1);
} w
![]() |
Other Threads in the C# Forum
- Previous Thread: Writing to INI file issue
- Next Thread: Update a column in SQL using C#
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access algorithm array barchart bitmap box buttons c# chat check checkbox class client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees draganddrop drawing encryption enum event excel file files form format forms ftp function gdi+ httpwebrequest image index input install java label list listbox listener login mandelbrot math mouseclick mysql networking object operator oracle path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resource richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






