FUNCTION LastDOW(tddate AS Date) LOCAL lnweeks AS Integer, ldreturndate AS Date tddate = DATE() lnweeks = WEEK(tddate, 1, 1) - 1 ldreturndate = DATE(YEAR(tddate), 1, 1) + (lnweeks * 7) ldreturndate = ldreturndate + 7 - DOW(ldreturndate, 1) RETURN ldreturndate ENDFUNCUpdate: One reason for taking into consideration the first week of the year is that if the first day of the week changes, then all code that expects it to be a Sunday breaks. We've had this situation at work and we've been working on it for months. In the above, all you have to do is either change the parameter passed to the DOW() function.