*========================================================= * * FUNCTION: Week2Date * *========================================================= FUNCTION Week2Date * Created...........: 21.Mai 2002, 14:29 Uhr * Changed...........: * Description.......: Return the Date for the first * day of a given week-no * Calling Samples...: ? Week2Date(<ExpN1>[, <ExpN2>]) * Parameters........: tn_Week, tn_Year * Returns...........: Date lparameters tn_Week, tn_Year LOCAL ld_YearStart, ld_WeekStart tn_Week = iif(vartype(tn_Week) = "N", tn_Week, 1) tn_Year = iif(vartype(tn_Year) = "N", tn_Year, year(date())) #define cn_WeekStart 2 && The first week starts && with the first four-day-week #define cn_FirstDayOfWeek 2 && Monday is the first && day of the week *====================================* * First we get the day that starts * * the first week of the year. * * Thus lets go back a few days into * * the year before * *====================================* ld_YearStart = date(tn_Year, 1, 1) -5 do while .T. if week(ld_YearStart, cn_WeekStart, cn_FirstDayOfWeek) = 1 *===============================================* * Yes, the first week of the Year starts here * *===============================================* exit else ld_YearStart = ld_YearStart + 1 endif enddo *===================================* * OK, Now we have the Date that * * represents the first day of the * * year's first week. From that we * * should be able to easily * * calcualte the date of the week * * provided * *===================================* ld_WeekStart = ld_YearStart + ((tn_Week-1)*7) return ld_WeekStart *-- eof Week2DateHope this works for You