Post by Auric__Post by Evertjan.ISOweekNumber = DatePart("ww", theDate, vbMonday, vbFirstFourDays)
That took me a week.
Neat. Into ye olde book of tricks it goes.
Well, the reverce is not that simple,
the best I can do is this:
function ISOweekNumber(theDate)
ISOweekNumber = DatePart("ww", theDate, vbMonday, vbFirstFourDays)
end function
function dateFromISOweekNumber( theYear, IsoWkNr, Wkday ) ''' monday = 1
firstDayY = dateserial(theYear, 1, 1)
WeekNumberFirstDayY = ISOweekNumber(firstDayY)
WeekDayFirstDayY = weekday(firstDayY, vbMonday)
if WeekNumberFirstDayY <> 1 then firstDayY = firstDayY + 7
dateFromISOweekNumber = firstDayY - (WeekDayFirstDayY - 1) +
( 7 * (IsoWkNr -1 ) + (Wkday - 1))
end function
Anyone with a better/shorter, or more correct solution?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)