Skip to main content

How to convert week number to date or vice versa in Excel?

Author Xiaoyang Last modified

Working with dates and week numbers in Excel is a common need in business analytics, project planning, and reporting. For example, you might want to know which week a particular date falls in, or determine the date range for a specific week number in a given year. However, Excel does not provide direct built-in options to convert week numbers to full date ranges or quickly reverse the process. To address these needs, you can use a variety of formulas, VBA solutions, and other Excel features depending on your specific requirements and the volume of data you want to process. Below are several practical methods to handle this task in Excel.

Convert week number to date with formulas

Convert date to week number with formulas

Convert between week number and date with VBA codes


Convert week number to date with formulas

Suppose you have a specific year and a week number entered in your worksheet (for example, 2015 in cell B1 and 15 in cell B2). You may wish to calculate the actual start date (Monday) and end date (Sunday) of this week. This can be especially helpful in schedule planning, preparing weekly summaries, or referencing weekly reporting periods.
sample data

To calculate the date range for the specified week number, you can use the following Excel formulas:

1. Select a blank cell to display the start date (here, cell B5). Enter the folling formula, and press the Enter key. The formula will return a serial number representing the date.

=MAX(DATE(B1,1,1),DATE(B1,1,1)-WEEKDAY(DATE(B1,1,1),2)+(B2-1)*7+1)

2. For the end date of the same week (for example, in cell B6), enter the following formula, then press Enter. The formula will return the serial number for the last day of the specified week.

=MIN(DATE(B1+1,1,0),DATE(B1,1,1)-WEEKDAY(DATE(B1,1,1),2)+B2*7)

Convert week number to date with formulas

Note: In the formulas above, B1 is the cell containing the year (for example,2015), and B2 contains the week number you want to convert. Adjust these cell references for your actual worksheet as needed.

3. The formulas initially return numbers rather than formatted dates. To display the correct date format, select both formula cells, then go to Home > Number Format drop-down > Short Date. This will convert the values to recognizable dates.
format formula cells to date

Tips: These formulas are based on the ISO week date system (where weeks start on Monday), which is common in European payroll and reporting standards. If your organization uses a different week numbering system, results may vary. Always double-check outcomes for years that start mid-week (for instance, when January 1 is not a Monday) or years with 53 weeks.


Convert date to week number with formulas

Conversely, you may want to determine the week number in which a given date falls. Excel provides the WEEKNUM function for this purpose. This is particularly handy when analyzing timesheet data, generating weekly reports, or tracking deliveries and events by week.

1. Choose a blank cell for the output of the week number. Enter the following formula (assuming your date is in B1):

=WEEKNUM(B1,1)

2. Then, press Enter. This formula returns the week number considering Sunday as the first day of the week.
Convert date to week number with formula

Notes:

(1) In this formula, B1 is the cell containing the date you want to convert.

(2) If you prefer to count weeks starting from Monday (common in the ISO week system), use this version of the formula:

=WEEKNUM(B1,2)

Convert between week number and date with VBA codes

In this article, we’ll explore two VBA routines: one that converts a week number (and year) into its corresponding date range, and another that determines the ISO week number for any given date.

Convert week number to date range:

1. Open the VBA Editor by clicking Developer > Visual Basic. In the window that opens, click Insert > Module and paste the below code into the module:

Sub WeekNumberToDateRange()
    Dim YearNum As Long
    Dim WeekNum As Long
    Dim FirstDay As Date, LastDay As Date
    Dim Jan4 As Date
    YearNum = Application.InputBox("Enter the year:", "KutoolsforExcel", Year(Date), Type:=1)
    If YearNum < 1 Then Exit Sub
    WeekNum = Application.InputBox("Enter the week number:", "KutoolsforExcel", 1, Type:=1)
    If WeekNum < 1 Then Exit Sub
    Jan4 = DateSerial(YearNum, 1, 4)
    FirstDay = Jan4 - Weekday(Jan4, vbMonday) + 1
    FirstDay = FirstDay + (WeekNum - 1) * 7
    LastDay = FirstDay + 6
    MsgBox "Start date: " & Format(FirstDay, "yyyy-mm-dd") & vbCrLf & _
           "End date:   " & Format(LastDay, "yyyy-mm-dd"), _
           vbInformation, "KutoolsforExcel"
End Sub 

2. Run the macro using the Run button button. It will prompt you for the year and week number, then display the respective date range in a dialog box.

Convert date to week number:

1. Copy and paste the following VBa code into the module:

Sub DateToWeekNumber()
 Dim InputDate As Date
 Dim WeekNum As Integer
 InputDate = Application.InputBox("Enter the date (yyyy-mm-dd):", "KutoolsforExcel", Date, Type:=2)
 WeekNum = WorksheetFunction.WeekNum(InputDate, 2)
 MsgBox "The week number is: " & WeekNum, vbInformation, "KutoolsforExcel"
End Sub  

2. After inserting and running this code, enter your target date when prompted and the macro will show the week number, counting Monday as the start of the week. You can modify the code by changing the second argument in WeekNum to 1 for weeks starting on Sunday.

Tips: If your week system is different, adjust the vbMonday or vbSunday in the VBA code accordingly.

One click to convert multiple non-standard formatting dates to normal dates in Excel

Kutools for Excel's Convert to Date utility can help you easily identify and convert non-standard dates or numbers (such as yyyymmdd) or plain text into standard date formats with only one click in Excel, improving productivity and reducing manual conversion errors. Get a30-day full-featured free trial now!
ad convert to date


Related articles:

How to count the number of specific weekdays between two dates in Excel?

How to add / subtract days / months / years to date in Excel?

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!