C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » .NET »

find number of sundays in a given month(c#) --very urgent


Posted Date: 16 Feb 2006      Posted By: sheetal nayak      Member Level: Bronze     Points: 2   Responses: 1



i want to know how to find number of sundays in a given month using c#.
please help
its very urgent

thanx in advance





Responses

Author: Abhishek Arya    16 Feb 2006Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

use this code

private int NumMondays(string month_name, string year_name)
{
int i;
int num_mondays;
System.DateTime test_date;
int orig_month;
test_date = System.Convert.ToDateTime(month_name + " 1, " + year_name);
if (Weekday(test_date) == vbMonday) {
} else if (Weekday(test_date) == vbTuesday) {
test_date = DateAdd("d", 6, test_date);
} else if (Weekday(test_date) == vbWednesday) {
test_date = DateAdd("d", 5, test_date);
} else if (Weekday(test_date) == vbThursday) {
test_date = DateAdd("d", 4, test_date);
} else if (Weekday(test_date) == vbFriday) {
test_date = DateAdd("d", 3, test_date);
} else if (Weekday(test_date) == vbSaturday) {
test_date = DateAdd("d", 2, test_date);
} else if (Weekday(test_date) == vbSunday) {
test_date = DateAdd("d", 1, test_date);
}
orig_month = Month(test_date);
do {
num_mondays = num_mondays + 1;
test_date = DateAdd("ww", 1, test_date);
} while ((Month(test_date) == orig_month));
NumMondays = num_mondays;
}



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Is there any expert to solve this?
Previous : what is difference between String and string(data type) in c#?
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use