logo ASAP Utilities

Excel tip: Get the date from a weeknumber

Date: 25 february 2003

Copy-paste friendly code:
Function fnDateFromWeek(iYear As Integer, iWeek As Integer, iWeekDday As Integer)
' get the date from a certain day in a certain week in a certain year
      fnDateFromWeek = _
      DateSerial(iYear, 1, ((iWeek - 1) * 7) + iWeekDday - Weekday(DateSerial(iYear, 1, 1)) + 1)
End Function


Sub TestExample()
      Debug.Print Format(fnDateFromWeek(2002, 42, 2), "ddd dd mmm yyyy") ' mo 14 Oct 2002
      Debug.Print Format(fnDateFromWeek(2002, 42, 6), "ddd dd-mmm-yyyy") ' fr 18 Oct 2002
End Sub



« back

Home Privacy Policy Cookie Policy EULA Download All added Excel tools Sitemap Contact Us


Empowering Excel Users Worldwide for 25 Years