C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






Week of the Year


Posted Date: 03 Apr 2008    Resource Type: Code Snippets    Category: Date & Time

Posted By: Raju.M       Member Level: Gold
Rating:     Points: 5



The code sample is a ASP.NET page's code behind file that tries to output the week of the year, given the date.

For example, if the input date is Jan 1,2008, then it's the first week of the year. In the code below, the getWeek() function is responsible for returning the week's number.



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());
}
public int getWeek()
{

DateTime date = DateTime.Now;
System.Globalization.CultureInfo cult_info = System.Globalization.CultureInfo.CreateSpecificCulture("no");
System.Globalization.Calendar cal = cult_info.Calendar;
int weekNo = cal.GetWeekOfYear(date, cult_info.DateTimeFormat.CalendarWeekRule, cult_info.DateTimeFormat.FirstDayOfWeek);
return weekNo;

}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Week of the year  .  Week number of the year  .  Week number  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Comparing DateTime objects
Previous Resource: Get ZodiacSign
Return to Discussion Resource Index
Post New Resource
Category: Date & Time


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use