A step by step tutorial teaching you how to create your own chat client and chat server easily in C#, for local networks or the Internet.
A C# tutorial showing you how to make use of WMI to extract information on disk drives, such as model, capacity, sectors and serial number.
This tutorial will teach you how to calculate the shipping cost based on the weight, height, length and depth of the box, the distance and the UPS service type.
Creating a Rich Text Editor using JavaScript is easier to do than you might think, thanks to the support of modern browsers; this tutorial will walk you through it.
Get the week number of a given dateThe C# method uses the DateTime object to get the week number of a given date. The number returned is dependent on the culture of the target machine. |
On Wednesday, January 9th 2008 at 10:51 PM By Andrew Pociu (View Profile) ![]() ![]() ![]() ![]() (Rated 4.9 with 14 votes) |
||
|
|||
Digg It!
Del.icio.us
Reddit
StumbleIt
Newsvine
Furl
BlinkList
|
|||
|
|||
Current Commentsdsfgdsfg
Excellent solution!
That example was very helpfull.
Don't forget to add: using System.Globalization;
Thanks for giving such a nice thing
Thanks!!!!
Would be nice if this actually worked in all cultures - but it doesn't.
Re: Lars
Would be nice if you detailed why/when it doesn't. Please, be Open with your knowledge. ;)
Yes, of course; sorry.
It fails because Microsoft's function simply does not return the correct weeknumber; at least not in my country. I live in Denmark, and it fails to get the first and last week of the year right, seemingly Every time.
Thanks a lot for posting this! One point about culture dependence is DayOfWeek.Monday is not the right choice for some cultures. DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek will give you the DayOfWeek enum value that is culture dependent. Lars, try using CalendarWeekRule.FirstDay instead of FirstFourDayWeek, that gave me the results I was looking for.
What is dtPassed?
i need to display week number of month
can any one post this answer
Take the first, last, middle, or whatever day from the month and run that through the above function
Thanks for being so helpful!
Use CreateSpecificCulture("no")
For ISO-8601
Thanks
Thanks for this code snippet it's very usefull
Good work thanks :)
This might be useful for some to work it the other way - date of week: http://stackoverflow.com/questions/662379/calculate-date-from-week-number
thank u v much realy this sample example make me do what i want effortless
g'__
Hi If you want a day number of week for current date then you can simply do
DatetTime viewDate = DateTime.Now;
int weekday = (int)viewDate.DayOfWeek;
will give you 5 - for Friday and so forth.
Hope it will be helpful to somebody who just want to do simple things.
Thanks.Nice and quick solution
Get the week number of DateTime
it's really good.
Superb. Thanks alot!!!
Cheers!
Your journal is so municipality that every one would undergo pleasure to valuation comments. So am I. Thanks.
I somebody been municipality out any of your posts and i can rely pretty groovy move. I cognition definitely bookmark your powerfulness.
Your post looks great! I enjoyed.Thanks you for sharing. I love it.
Your personal know-how and kindness in maneuvering every part was tremendous. I am not sure what I would've done if I hadn't encountered such a solution like this. I'm able to at this time look ahead to my future. Thanks a lot so much for the specialized and result oriented help. I won't hesitate to endorse the blog to anybody who desires assistance on this topic.
Your personal know-how and kindness in maneuvering every part was tremendous. I am not sure what I would've done if I hadn't encountered such a solution like this. I'm able to at this time look ahead to my future. Thanks a lot so much for the specialized and result oriented help. I won't hesitate to endorse the blog to anybody who desires assistance on this topic.
Your personal know-how and kindness in maneuvering every part was tremendous. I am not sure what I would've done if I hadn't encountered such a solution like this. I'm able to at this time look ahead to my future. Thanks a lot so much for the specialized and result oriented help. I won't hesitate to endorse the blog to anybody who desires assistance on this topic.
I truly wanted to write a quick message to thank you for some of the splendid points you are showing at this website. My long internet investigation has at the end been compensated with sensible facts and techniques to share with my family and friends.
I truly wanted to write a quick message to thank you for some of the splendid points you are showing at this website. My long internet investigation has at the end been compensated with sensible facts and techniques to share with my family and friends.
I would believe that we visitors are truly blessed to dwell in a wonderful network with many wonderful professionals with very beneficial hints. I feel extremely privileged to have seen the web pages and look forward to many more pleasurable times reading here. Thank you once again for everything.
I would believe that we visitors are truly blessed to dwell in a wonderful network with many wonderful professionals with very beneficial hints. I feel extremely privileged to have seen the web pages and look forward to many more pleasurable times reading here. Thank you once again for everything.
Thanks so much for providing individuals with an extremely remarkable possiblity to read critical reviews from this web site. It is always so beneficial plus jam-packed with a great time for me personally and my office friends to search the blog at the least three times in one week to see the fresh secrets you will have.
Thanks so much for providing individuals with an extremely remarkable possiblity to read critical reviews from this web site. It is always so beneficial plus jam-packed with a great time for me personally and my office friends to search the blog at the least three times in one week to see the fresh secrets you will have.
I am just always happy with your good tips and hints served by you. Some 1 areas in this article are undeniably the finest I've had.
I am just always happy with your good tips and hints served by you. Some 1 areas in this article are undeniably the finest I've had.
I am just always happy with your good tips and hints served by you. Some 1 areas in this article are undeniably the finest I've had.
Thanks a lot for providing individuals with remarkably special possiblity to read critical reviews from this web site. It can be very kind plus packed with a great time for me personally and my office mates to visit your site no less than three times weekly to study the newest tips you have.
Thanks a lot for providing individuals with remarkably special possiblity to read critical reviews from this web site. It can be very kind plus packed with a great time for me personally and my office mates to visit your site no less than three times weekly to study the newest tips you have.
Once you have recreated the problem and captured these steps, you can save them to a file and send it to your support person, who can then open it up and view
I truly wanted to write a quick message to thank you for some of the splendid points you are showing at this website. My long internet investigation has at the end been compensated with sensible facts and techniques to share with my family and friends.
http://www.getscoachoutletonline.org/ Coach Outlet Online
http://www.coachoutlets-canadas.org/ Coach Outlet Online
http://www.coachoutletpursea.org/ Coach Bags Outlet
http://www.coachoutletonline-purse.net/ Cheap Coach Handbags
http://www.coachfactorye.net/ Coach Factory
http://www.coachoutletusonline2012.net/ coach outlet online
http://www.louisvuittonpurse-outlets.net/ louis vuitton bags
http://www.coachoutlets4u.org/ coach outlet store online
http://www.coachfactorystorea.com/ Coach Factory Outlet
http://www.coachoutletusshop.org/ coach outlet
http://www.buycoachoutletinfactory.org/ coach factory outlet
It is so lucky to read your blog,it is full of useful message.I wish we both can do better in the future.It great honor if you can visit our website,and give us some suggestion. writing a essay
mates to visit your site no less than three times weekly to study the newest tips you have.
This is such a great resource that you are providing and you give it away for free. I love seeing websites that understand the value of providing a quality resource for free. It is the old what goes around comes around routine.http://www.genesishealthinstitute.com/testosterone.php
Hi,
I can't get GetWeekOfYear function to work right. It gives the wrong week number at the end of year if the date is December 31, 2012.
My country is Finland, so the culture should be "fi". We use here the rule that first week of year is the first week that has four days on the year. The first day of week is monday. I think my settings are right. This still gives the wrong answer. I have the same problem as Lars.
Dim ciCurr As CultureInfo = CultureInfo.CreateSpecificCulture("fi")
Dim weekNum As Int32 = ciCurr.Calendar.GetWeekOfYear( _
dtValue, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday)
public int GetWeekOfYear(DateTime todayDate)
{
int days = todayDate.DayOfYear;
float result = days / 7;
result=result 1;
Response.Write(result.ToString());
return Convert.ToInt32(result);
}
just pass the current date then u will get the current week number....
College graduates are grateful for competent ideas and clever materials. Not so many are aware of this fact. Reasonably cheap essay writer service is not likely to be underestimated by student.
Related Source Code
Related Tutorials
C# Job SearchFrom the creators of Geekpedia, a revolutionary new coupon website!
BargainEZ has coupons codes, printable coupons, bargains and it is the leading source of Passbook coupons for iPhone and iPod touch devices.