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:
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?
its all automatically generated namespaces.will make better next time
Anonymous, dont be rude. It is not nice.
Anonymous, dont be rude. It is really not nice.
Anonymous, dont be rude. It is really not nice.
Post a Comment