In this tutorial, you will learn how to get week number from date. This is possible by using Excel WEEKNUM function. Also, you will get familiar with three different ways to get week number from a date, depending on starting week definition. Based on the selected type of calculating the week number, the function will set the first week of a year.
Get week number from a date
The function WEEKNUM returns a week number of a selected date. The parameters of the function are date – a date for which we want to calculate week number in a year; return_type – a non-mandatory parameter, which tells the function how to calculate weeks in a year. The possible values are:
1 – the first week of a year begins on January 1, while the second week begins on the next Sunday;
2 – the first week of a year begins on January 1, while the second week begins on the next Monday;
21 – ISO week numbers: the first week begins on the first Monday between December 29 and January 4.
If this parameter is omitted, the WEEKNUM function will by default set it to 1 when we want to get week number from date.
In the example we will see how to get week number from date:
Figure 1. Get week number from a date
The dates for which we want to calculate week number are in column B (“Date”) and also the week number will be in column C (“Week number”). For the date in B3 (24-Feb-18) the function returned to 8 in cell C3 because the selected date is in the 8th week of the 2018 year.
Also, if we wanted to use return type parameter and define the type of calculating weeks, we could have set it in the function. For example, the function to get week number from a date with ISO weeks would look like: