Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WeekOfYear Function 1

Status
Not open for further replies.

dkn

Programmer
Oct 11, 2000
60
US
Hi All,

Does anyone know if there is an ASP Function that works in reverse to the WeekOfYear function. As an example, I have a table that stores the Week as an integer between 1 and 52, and also the year. I want a function that I can supply these two arguments, and get the date of the Monday of that week returned?.

Haven't been able to find one, but just thought I'd check before I reinvent the wheel.

TIA

David
 
This should work, assuming vbFirstJan1 definition of first week of year:
Code:
Function BoWY( iYear, iWeek)
	Dim dRet
	dRet = DateSerial(iYear, 1, 1) ' beginning of year
	dRet = dRet - DatePart("w", dRet, vbMonday) + 1 ' locate Monday
	dRet = dRet + (iWeek-1)*7 ' N-1 week forward

	BoWY = dRet
End Function

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Thanks vongrunt,

I'll give it a wizz and see how it goes.

David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top