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
Share this page:
Home Sitemap Search List of all utilities Printer friendly page ^ Back to Top
© 1999-2017 - - - - The Netherlands

Connect with us and receive our tips that show you how to benefit from the tools in ASAP Utilities at:
Follow us on TwitterFollow us on Facebook