Calculate first day in current week

PetCar
06-10-2002, 08:14 AM
Hi!

I need some help with a small function.
I want to do a function like this;


Public Function firstdayofweek(weeknumber,year)
End Function
06/06/2002 = firstdayofweek("24","2002")


Any clues.. i hate dateformatting.. :)

Regards /
Peter Carlsson

ChiefRedBull
06-10-2002, 08:18 AM
What have you got so far, and where are you having problems?

PetCar
06-10-2002, 08:26 AM
I solved it just a few minutes ago.
Found some code in this VB forum that i fixed to suite me.

// Peter


Public Function getWeekDate(myWeek, myYear)
Dim Jan1st
Dim firstSunday
Jan1st = DateSerial(myYear, 1, 1) ' get 1/1/yyyy
firstSunday = Jan1st - Weekday(Jan1st) + 2
If DatePart("ww",Jan1st,2,vbFirstFourDays) <> 1 Then
firstSunday = firstSunday + 7
End If
getWeekDate = firstSunday + 7 * (myWeek - 1)
End Function

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum