Query: Find out week in between two year's.
public void weekly()
{
int startdate = 2011;
int endDate = 2012;
string s = string.Empty;
DateTime dtStart = new DateTime(startdate, 4, 1);
DateTime dtEnd = new DateTime(endDate, 3, 31);
DateTime dtTemp2 = default(DateTime);
DateTime dtTemp = default(DateTime);
while (dtStart <= dtEnd)
{
dtTemp = dtStart.AddDays(6);
if (dtTemp < dtEnd)
s = s + dtStart.ToString("dd MMMM yyyy") + " - " + dtTemp.ToString("dd MMMM yyyy") + "\r\n\n";
else
{
s = s + dtStart.ToString("dd MMMM yyyy") + " - " + dtEnd.ToString("dd MMMM yyyy") + "\r\n\n";
break;
}
dtTemp2 = dtTemp.AddDays(1);
dtStart = dtTemp2;
}
Response.Write(HttpUtility.HtmlEncode(s).Replace("\n", "<br />"));
}
No comments :
Post a Comment