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
12
votes
3 answers
calculate the month from the year and week number in excel
In Excel 2007 I have a Year number and Week number and I want to work out the Month number.
The catch is that in my case the start of every week is a monday, so some weeks will overlap through the years.
Examples:
Year: 2012
Week 1 started: Monday…

Pricey
- 5,799
- 12
- 60
- 84
11
votes
5 answers
Get week number with week start day different than monday - Python
I have a dataset with a date column. I want to get the week number associated with each date.
I know I can use:
x['date'].isocalendar()[1]
But it gives me the week num with start day = monday. While I need the week to start on a friday.
How do you…

No94
- 155
- 1
- 1
- 7
11
votes
6 answers
How to find total weeks of a year in Java?
I am working on a project. There I should find the total weeks of a year. I tried with the following code, but I get the wrong answer: 2020 has 53 weeks, but this code gives 52 weeks.
Where have I gone wrong in this code?
package…

Kumaresan Perumal
- 1,926
- 2
- 29
- 35
11
votes
2 answers
GregorianCalendar setFirstDayOfWeek not affecting WEEK_OF_YEAR on pre Nougat
The code below gives a different result on Nougat and pre-Nougat. Take a look and try it yourself if you want. I would appreciate it if someone could explain me why and give a solution.
I want the correct WEEK_OF_YEAR value, dependent on the first…

Robin Dijkhof
- 18,665
- 11
- 65
- 116
11
votes
2 answers
API21 new DatePicker ShowWeekNumber Crash
I was testing my app with the new Android 5.0 (API21) but was getting an error with the CalendarView
Caused by: java.lang.UnsupportedOperationException: CalendarView does not exists for the new DatePicker
at…

pvalle
- 1,335
- 1
- 13
- 20
11
votes
5 answers
How to Get the number of weeks in a given year
Trying to code a correct function that returns the number of weeks in a given year, but without success.
Example of the function I'm looking for :
int weeks = GetWeeksInYear ( 2012 )
should return 52 weeks // means there are only 52 weeks in…

illusion
- 383
- 2
- 4
- 9
11
votes
3 answers
SQLite return wrong week number for 2013?
I have a simple SQL for calculating week number in my reports on SQLite
SELECT STRFTIME('%W', 'date_column')
It was correct for 2009-2012. In 2013 I got always the wrong week number.
For example
SELECT STRFTIME('%W', '2012-02-28')
return '09' and…

WebDucer
- 1,114
- 2
- 16
- 39
10
votes
3 answers
Calculating the number of weeks in a year with Ruby
Is there a way in Ruby to calculate the number of weeks(ISO 8601) for a given year? I'm currently using a lookup table and I'd like to stop using it.

rwilliams
- 21,188
- 6
- 49
- 55
10
votes
3 answers
How to calculate Date from ISO8601 week number in Java
Is there any way of doing this: How to get dates of a week (I know week number)? for ISO 8601 week number without using any library or calender in Java?

mjh
- 123
- 1
- 4
9
votes
2 answers
weekofyear() returning seemingly incorrect results for January 1
I'm not quite sure why my code gives 52 as the answer for: weekofyear("01/JAN/2017") .
Does anyone have a possible explanation for this? Is there a better way to do this?
from pyspark.sql import SparkSession, functions
spark =…

Grant Shannon
- 4,709
- 1
- 46
- 36
9
votes
3 answers
How to group by week in Entity Framework Core?
In Entity Framework 6 I can use SqlFunctions.DatePart() method:
var byWeek = data.GroupBy(x => SqlFunctions.DatePart("week", x.Date));
But these classes (DbFunctions and SqlFunctions are not available in Entity Framework Core) (reference).
So my…

Nikolay Kostov
- 16,433
- 23
- 85
- 123
9
votes
3 answers
Group dates by week in R
I wish to label my data based on their week. This is my data:
df2 <- structure(list(Order_Date = structure(c(16735, 16805, 16753,
16830, 17075, 17009, 17085, 16740, 16891, 16750, 16820, 16849,
16906, 16929, 16746, 16731, 16786, 16873, 16895,…

MFR
- 2,049
- 3
- 29
- 53
9
votes
3 answers
In .net, knowing the week number how can I get the weekdays date?
I want to create a function in C# which for a week number will return me the days, in that week.
For instance for week number 40, how can I get the days:
4/10, 5/10, 6/10, 7/10, 8/10, 9/10, 10/10.
Thank you in advance!
user171910
9
votes
4 answers
Postgres partition by week
I can imagine table partition by a date (in particular for logs) is something widely used, but I am not able to find a good answer to my problem.
I want to create a table partition by week (the number of records is to big to make it monthly). The…

RGPT
- 564
- 1
- 7
- 16
8
votes
3 answers
Joda-Time: Get max number of weeks for particular year
How do I get the maximum number of weeks for a particular year with Joda-Time?

cody
- 6,389
- 15
- 52
- 77