'********************************************************************************************************** ' Name: weeksDifference ' Author: mielk | 2012-06-15 ' ' Comment: Function to count the difference in weeks between two dates. ' ' Parameters: ' startDate Start date. ' endDate End date. ' firstDayOfWeek Day assumed to be the first day of the week. ' ' Returns: ' Long The number of weeks between two given dates. ' If both dates were in the same week, 0 is returned. ' If the given end date is later than the start date, negative value is returned. ' ' ' --- Changes log ----------------------------------------------------------------------------------------- ' 2012-06-15 mielk Function created. '********************************************************************************************************** Public Function weeksDifference(startDate As Date, endDate As Date, _ Optional firstDayOfWeek As VBA.VbDayOfWeek = vbMonday) As Long Const METHOD_NAME As String = "weeksDifference" '------------------------------------------------------------------------------------------------------ weeksDifference = VBA.DateDiff("ww", startDate, endDate, firstDayOfWeek, VBA.vbFirstFourDays) End Function