Adsence750x90

Monday, April 7, 2008

Get Week Of The Year in C# ASP.NET - sample source code


Get Week Of The Year

C# ASP.NET code For get WEEk from a year.


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class WeekCalc : System.Web.UI.Page
{

protected void Page_Load(object sender, EventArgs e)
{
Response.Write(getWeek(DateTime.Now));
}
public int getWeek(DateTime date)
{
System.Globalization.CultureInfo cult_info = System.Globalization.CultureInfo.CreateSpecificCulture("no");
System.Globalization.Calendar cal = cult_info.Calendar;
int weekCount = cal.GetWeekOfYear(date, cult_info.DateTimeFormat.CalendarWeekRule, cult_info.DateTimeFormat.FirstDayOfWeek);
return weekCount;

}


5 comments:

Anonymous said...

You don't need all that System.Web crap in order to do this! And it's so obvious and already documented that it hardly needs an example to be published, does it?

Raju.M said...

its all automatically generated namespaces.will make better next time

Unknown said...

Anonymous, dont be rude. It is not nice.

Unknown said...

Anonymous, dont be rude. It is really not nice.

Unknown said...

Anonymous, dont be rude. It is really not nice.