Based on Gregorain calendar, every week of a year has a number from 1 to 52, 53 or 54. Use this tag for instance if you want to calculate the weeknumber from a certain date or vice versa. You also might include the date tag. This tag is independent of programming language.
Questions tagged [week-number]
603 questions
8
votes
4 answers
Function Getting the right week number of year
I want to create a function to get the right week number of year.
I already posted here to find a 'native' solution, but apparently there is not.
I tryed to create funcrtion based on this mysql example
Here is the code translated to…

Houari
- 5,326
- 3
- 31
- 54
8
votes
4 answers
How to get year-sensitive calendar week ? date("W") gives back 52 for 1st of January
As the headline says, PHP's date("W") function gives back the calendar week (for the current day). Unfortunatly it gives back 52 or 53 for the first day(s) of most years. This is, in a simple thinking way, correct, but very annoying, as January 1st…

Sliq
- 15,937
- 27
- 110
- 143
7
votes
1 answer
Windows 8: Show week numbers in mini calendar
I want to see week numbers if I click on the mini calendar at the bottom right corner in Windows 8 (and probably 7 I guess). My system is running under Win8.1 Pro.
The image shows what I mean:
http://s7.directupload.net/images/140904/c7a88vg9.jpg
As…

BAERUS
- 4,009
- 3
- 24
- 39
7
votes
1 answer
Week of year calculation differences among Java and multi SQL RDBMS
I have to do some reports and have to calc week of any date in Java and in MySQL
but they have different algorithms.
Firstly, note that by some methods, in some days in the end of some year is the first week of the next year. Examples: 2012-12-31 is…

yelliver
- 5,648
- 5
- 34
- 65
7
votes
1 answer
Explain why Dec 31 2012 is week 53 and not week 1 (ISO-8601)
I'm trying to write a function in JavaScript that returns the week number for a given date and I'm testing my code against two functions I've found on the web,…

wubbewubbewubbe
- 711
- 1
- 9
- 20
7
votes
3 answers
Ruby On Rails, week number is not the correct one (-1)
I need the current week number, if I'm not totally mistaken it's week 51 right now? However when testing it in the console I get this.
Time.now
=> 2013-12-19 11:08:25 +0100
Time.now.strftime('%U')
=> "50"
Date.today
=> Thu, 19 Dec…

Philip
- 6,827
- 13
- 75
- 104
7
votes
10 answers
How to get weeks starting on sunday?
I need to get week number in php where week should be calculated from sunday. By default its from monday. Please help me to find a way how to get week number considering sunday as starting day.
In php manual
ISO-8601 week number of year, weeks…

Hriju
- 728
- 1
- 16
- 27
7
votes
4 answers
How to calculate week number for given date Android
I am trying to get the the current week number from the given date. i.e. If I enter the date as 01/03/2013 then i should get the week number which is 9..
Please help me in finding the solution..
Thanks..
Abhishek..

Abhishek Dhiman
- 1,631
- 6
- 25
- 38
6
votes
1 answer
Get the week number from a date time
I am trying to get the week number from a date time and in my case, the first day of the week is Monday and I want to follow the FirstFourDays convention.
To check the results, I am checking this…

Álvaro García
- 18,114
- 30
- 102
- 193
6
votes
3 answers
ISO week number in CMD
How can I determine the (ISO 8601) week number in a Windows batch file?
Unfortunately WMIC PATH WIN32_LOCALTIME GET /FORMAT:LIST only has WeekInMonth...
I have found some very complex solutions. Is there no easier way?

Michel de Ruiter
- 7,131
- 5
- 49
- 74
6
votes
6 answers
Group by Week of year (Week number) in Linq to SQL
In regular SQL i could do something like
SELECT * From T GROUP BY DATEPART(wk, T.Date)
How can i do that in Linq to SQL ?
The following don't work
From F In DB.T Group R By DatePart(DateInterval.WeekOfYear, F.Date)
Also don't work:
From F In DB.T…

ariel
- 15,620
- 12
- 61
- 73
6
votes
5 answers
Get the number of the week of the month from a given date
I have a set of dates from which I must obtain the week of the month.
There is a lot of literature on how to obtain the week of the year using VBA code but not the week number of the month.
For instance 03-Mar-13 would give week 1 of March, instead…

user2453446
- 293
- 3
- 5
- 14
5
votes
2 answers
gnuplot: How to get correct week numbers?
Originating from this question gnuplot why warning: Bad time format in string,
there was the finding that the week numbers in gnuplot using the time specifiers %W and %U are wrong in some cases.
Apparently, there are different definitions of the…

theozh
- 22,244
- 5
- 28
- 72
5
votes
3 answers
How to calculate if a year has 53 weeks
According to formula https://en.wikipedia.org/wiki/ISO_week_date in the Weeks per year section you should be able to find each year with 53 weeks. I have copied the formula into PHP but it seems to mess up around 2020 returning 52 weeks instead of…

Mike Lewis
- 140
- 1
- 9
5
votes
2 answers
Missing Week in PHP's DateTime->modify('next week')
I think I am fully aware of ISO 8601 and that the first week of a year is the week that has a Monday in it. However I came across a strange behavior in PHP (5.6) DateTime Class.
Here is my code:
$start = new DateTime('2009-01-01 00:00');
$end = new…

Steven M
- 574
- 4
- 20