Click here to Skip to main content
13,356,318 members (61,994 online)
Click here to Skip to main content
Alternatives (3)
Add your own
alternative version

Tagged as


6 bookmarked
Posted 15 Jul 2011

DateTime Extension Method to Give Week Number

, 15 Jul 2011
Strangely, the .NET DateTime does not provide a Week Number. This extension rectifies this.


Members may post updates or alternatives to this current article in order to show different approaches or add new features.

6 Sep 2011
What about that :CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(pd_date, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
8 Sep 2011
Jani Giannoudis
Here another approach taken from my article Time Period Library for .NET[^], which returns addditional the year of the week.// ------------------------------------------------------------------------public enum YearWeekType{ Calendar, Iso8601,} // enum YearWeekType //...
19 Jul 2011
Gustav Brock
There certainly is a direct method in .NET to obtain the ISO week number. However, it is buggy, as ISO week numbering has been from VB 3.0 and Access Basic (of Access 1.0) through VBA of Office 2016, and not resolved in .NET. Fortunately, a tiny test for week 53 will get it right.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Wales Wales
Born at an early age, he grew older. At the same time, his hair grew longer, and was tied up behind his head.
Has problems spelling the word "the".
Invented the portable cat-flap.
Currently, has not died yet. Or has he?

| | Privacy | Terms of Use | Mobile
Web04 | 2.8.180111.1 | Last Updated 15 Jul 2011
Article Copyright 2011 by OriginalGriff
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid