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
156
votes
26 answers
Calculate date from week number
Anyone know an easy way to get the date of the first day in the week (monday here in Europe). I know the year and the week number? I'm going to do this in C#.

Bobby
- 2,074
- 3
- 15
- 14
117
votes
19 answers
Get the week start date and week end date from week number
I have a query that counts member's wedding dates in the database.
SELECT
SUM(NumberOfBrides) AS [Wedding Count]
, DATEPART( wk, WeddingDate) AS [Week Number]
, DATEPART( year, WeddingDate) AS [Year]
FROM MemberWeddingDates
GROUP BY…

digiguru
- 12,724
- 20
- 61
- 87
90
votes
8 answers
How to get week numbers from dates?
Looking for a function in R to convert dates into week numbers (of year) I went for week from package data.table.
However, I observed some strange behaviour:
> week("2014-03-16") # Sun, expecting 11
[1] 11
> week("2014-03-17") # Mon, expecting…

Christian Borck
- 1,812
- 1
- 13
- 19
76
votes
4 answers
Moment.js get the week number based on a specific day (also past years)
How could I get from moment JS the week number from a date in the past only from a moment formatted object from a day selected?

Arthur Kovacs
- 1,710
- 2
- 17
- 24
53
votes
2 answers
Get date from ISO week number in Python
Possible Duplicate:
What’s the best way to find the inverse of datetime.isocalendar()?
I have an ISO 8601 year and week number, and I need to translate this to the date of the first day in that week (Monday). How can I do this?
datetime.strptime()…

Erik Cederstrand
- 9,643
- 8
- 39
- 63
50
votes
2 answers
Get Week Number of LocalDate (Java 8)
I'm trying to get the Week Number of a full LocalDate with the format:
dd.MM.yyy
I haven't found a function in the Java 8 Date API wich returns the Week Number and i have tried to create a algorithm, but it did'nt work.

YvesHendseth
- 1,149
- 1
- 10
- 27
45
votes
23 answers
Week number of the month?
Does python offer a way to easily get the current week of the month (1:4) ?

Joao Figueiredo
- 3,120
- 3
- 31
- 40
31
votes
6 answers
Why dec 31 2010 returns 1 as week of year?
For instance:
Calendar c = Calendar.getInstance();
DateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
c.setTime( sdf.parse("31/12/2010"));
out.println( c.get( Calendar.WEEK_OF_YEAR ) );
Prints 1
Same happens with Joda time.
:)

OscarRyz
- 196,001
- 113
- 385
- 569
19
votes
19 answers
Get week number in month from date in PHP?
I have an array of random dates (not coming from MySQL). I need to group them by the week as Week1, Week2, and so on upto Week5.
What I have is this:
$dates = array('2015-09-01','2015-09-05','2015-09-06','2015-09-15','2015-09-17');
What I need is…

Asif Hussain
- 341
- 1
- 2
- 11
18
votes
4 answers
System.Globalization.Calendar.GetWeekOfYear() returns odd results
I'm in the middle of calculating week numbers for dates, but the System.Globalization.Calendar is returning odd results for (amongst other years) December 31st of year 2007 and 2012.
Calendar calendar = CultureInfo.InvariantCulture.Calendar;
var…

sshow
- 8,820
- 4
- 51
- 82
15
votes
7 answers
Is .NET giving me the wrong week number for Dec. 29th 2008?
According to the official (gregorian) calendar, the week number for 29/12/2008 is 1, because after the last day of week 52 (i.e. 28/12) there are three or less days left in the year. Kinda weird, but OK, rules are rules.
So according to this…

rodbv
- 5,214
- 4
- 31
- 31
14
votes
3 answers
PHP date('W') vs MySQL YEARWEEK(now())
Can someone kindly explain me why these two give different results?
I execute this with PHP.
date("YW",mktime(0, 0, 0, 3, 22 , 2013)); // outputs 201312
And when I execute this with MySQL
SELECT YEARWEEK(now()); // outputs 201311

Prasad Rajapaksha
- 6,118
- 10
- 36
- 52
14
votes
2 answers
Calculate the week number (0-53) in year
I have a dataset with locations and dates. I would like to calculate week of the year as number (00–53) but using Thursday as the first day of the week. The data looks like this:
location <- c(a,b,a,b,a,b)
date <-…

Eco06
- 531
- 2
- 8
- 17
12
votes
3 answers
How can I determine the week number of a certain date?
I'm trying to make a calendar using wpf. By using itemsPanel and more, I have a grid with 7 columns(sunday-saturday) and 6 rows(week# of month). If i can find the starting position of the first of each month by getting the weekday and week number(of…

TMan
- 4,044
- 18
- 63
- 117
12
votes
3 answers
Get week of month C#
I want to find a date are now on week number with c# desktop Application.
I've been looking on google, but none that fit my needs.
How do I get a week in a month as the example below?
Example:
I want January 6, 2014 = the first week of January…

Enkhay
- 232
- 2
- 4
- 16