Hi all,
I need to find all weeks of the current year.
currentyear=2009
weeks of 2009 (week 1, 2, 3, 4, 5, 6, 7, 8 ...)
and later to find the corresponding date for the specific week:
week=3;
date of week 3=(18 january - 25 january)
Date and weeks
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Kirtan PatelRank #292 · 8.6K reputationPosted Nov 29, 2009, 11:59 AM EST
Here I coded solution to solve your problem
Code will Tell you date of Start Date of Week and Also Count total Weeks in Year
if my answer helps you then check "Do you like this answer" check box please :)
protected void Page_Load(object sender, EventArgs e)
{
//Calculate Days in Year
int currentYear = 2009;
int totaldays = Thread.CurrentThread.CurrentCulture.Calendar.GetDaysInYear(2009);
DateTime StartDateOfYear = DateTime.Parse("1/1/"+currentYear);
DateTime endDateOfYear = StartDateOfYear.AddDays(totaldays);
int totalweek=0;
//Add Week Dates in ListBox
for (DateTime d = StartDateOfYear; d <= endDateOfYear; d = d.AddDays(1))
{
//Assume that Week Starts from Sundays
if (d.DayOfWeek == DayOfWeek.Sunday)
{
ListBox1.Items.Add(d.ToShortDateString());
totalweek += 1;
}
}
//Write total Weeks in Year
Response.Write("total weeks in year = " + totalweek);
}