Gustav Brock
gustav at cactus.dk
Mon May 9 15:47:51 CDT 2011
Hi Steve If so, these functions may be useful for you: Public Function DateWeekFirst( _ ByVal datDate As Date, _ Optional ByVal lngFirstDayOfWeek As Long = vbUseSystemDayOfWeek) _ As Date ' Returns the first date of the week of datDate. ' lngFirstDayOfWeek defines the first weekday of the week. ' 2000-09-07. Cactus Data ApS. ' 2003-05-01. System settings used as default. ' No special error handling. On Error Resume Next ' Validate lngFirstDayOfWeek. Select Case lngFirstDayOfWeek Case _ vbMonday, _ vbTuesday, _ vbWednesday, _ vbThursday, _ vbFriday, _ vbSaturday, _ vbSunday, _ vbUseSystemDayOfWeek Case Else lngFirstDayOfWeek = vbUseSystemDayOfWeek End Select DateWeekFirst = DateAdd("d", vbSunday - Weekday(datDate, lngFirstDayOfWeek), datDate) End Function Public Function DateWeekLast( _ ByVal datDate As Date, _ Optional ByVal lngFirstDayOfWeek As Long = vbUseSystemDayOfWeek) _ As Date ' Returns the last date of the week of datDate. ' lngFirstDayOfWeek defines the first weekday of the week. ' 2000-09-07. Cactus Data ApS. ' 2003-05-01. System settings used as default. ' No special error handling. On Error Resume Next ' Validate lngFirstDayOfWeek. Select Case lngFirstDayOfWeek Case _ vbMonday, _ vbTuesday, _ vbWednesday, _ vbThursday, _ vbFriday, _ vbSaturday, _ vbSunday, _ vbUseSystemDayOfWeek Case Else lngFirstDayOfWeek = vbUseSystemDayOfWeek End Select DateWeekLast = DateAdd("d", vbSaturday - Weekday(datDate, lngFirstDayOfWeek), datDate) End Function /gustav >>> sturner at mseco.com 09-05-2011 20:31 >>> Got what I needed from a dlookup. Syntax is a problem. One comma or quote can mess up the whole thing. What I'm doing is fixing some code where we have to know the Month Start Date and Month End Date to run reports. Like March of this year started in February and ended in April. Our time is by the week and ends on Fridays. The guy that wrote the original code had all the dates in the code and each year we had to go change the code and add the next year. I though a table with the dates would be eaiser to pull from and write to. I can pull the dates from the accounting system with code and write to the table each year. I was fixing some other code for monthly dates and wanted to fix this also. Hopefully what I got will do the trick now. Steve A. Turner Controller Mid-South Engineering Co. Inc E-Mail: sturner at mseco.com and saturner at mseco.com