hi,
i have year calender. i want to count the days in a year. when i am select year in a dropdown i want to display the days count of that year.
and aslo i have to display the days count exclude sunday of the whole year.
pls help me.
its urjent, post code or give some demos link
Loading

Sachin KaliaRank #102 · 20.8K reputationPosted Aug 2, 2012, 10:54 PM EDT
Please go through the link below.
http://www.c-sharpcorner.com/Blogs/4202/
also the code snippet from the above link.
private int GetDaysInAYear(int year)
{
int days = 0;
for (int i = 1; i <= 12; i++)
{
days += DateTime.DaysInMonth(year, i);
}
return days;
}
Kindly pass teh dropdownvalue as an parameter as year.
Hope this make you happy.
Cheers .Net
Sachin KaliaRank #102 · 20.8K reputationPosted Aug 2, 2012, 10:54 PM EDT
Please go through the link below.
http://www.c-sharpcorner.com/Blogs/4202/
also the code snippet from the above link.
private int GetDaysInAYear(int year)
{
int days = 0;
for (int i = 1; i <= 12; i++)
{
days += DateTime.DaysInMonth(year, i);
}
return days;
}
Kindly pass the dropdown value as an parameter as year.
Hope this make you happy.
Cheers .Net
Farooque AliRank #7,940 · 231 reputationPosted Aug 2, 2012, 10:56 PM EDT
http://www.dbforums.com/mysql/981086-count-days-excluding-weekends.html
Jignesh TrivediRank #16 · 50.3K reputationPosted Aug 2, 2012, 11:50 PM EDT
try....
private static int GetDaysInAYearWithoutSunday(int year)
{
int days = 0;
for (int i = 1; i <= 12; i++)
{
int sundaycount = GetNumberOfSundays(i, year);
days = days += sundaycount;
}
return days;
}
private static int GetNumberOfSundays(Int32 Month, Int32 Year)
{
DateTime StartDate = new DateTime(Year, Month, 1);
Int32 iDays = DateTime.DaysInMonth(Year, Month);
DateTime EndDate = StartDate.AddDays(iDays - 1);
Int32 SundayCount = 0;
while (StartDate.DayOfWeek != DayOfWeek.Sunday)
{
StartDate = StartDate.AddDays(1);
}
SundayCount = 1;
StartDate = StartDate.AddDays(7);
while (StartDate <= EndDate)
{
SundayCount += 1; StartDate = StartDate.AddDays(7);
}
return iDays - SundayCount;
}
static void Main(string[] args)
{
int vvv = GetDaysInAYearWithoutSunday(2012);
}
hope this will help you.
VulpesRank #55 · 29.2K reputationPosted Aug 3, 2012, 2:17 AM EDT