Base your report on a query. In the query, include the fields you want to list on the report. Also create a calculated field, using the formula:
[DateStarted] - [DateSubmit]
Run this query - you should see numbers in the calculated column, representing the number of days between the two dates.
Now add the formula
>=6 to the Criteria line of this column, and run the query again. You should see only those records where the dates differ by six days or more.
To get the number of business days between the two dates, you could use this function which I wrote for one of my programs:
Code:
Function BusinessDays(dtStartDate As Date, dtEndDate As Date)
'Returns number of business days between two dates as an integer
'Returns -1 if the start date is greater than the end date
Dim intDayCount As Integer
Dim J As Integer
Dim dtNextDate As Date
'----------------------------------------------------------------
'- Set the first date to check -
'----------------------------------------------------------------
dtNextDate = dtStartDate
'----------------------------------------------------------------
'- Return error code of -1 if Start Date is later than End Date -
'----------------------------------------------------------------
If dtStartDate > dtEndDate Then
BusinessDays = -1
Else
'----------------------------------------------------------------
'- Loop through all dates between Start Date and End Date -
'----------------------------------------------------------------
Do Until dtNextDate >= dtEndDate
'----------------------------------------------------------------
'If it's a weekday (Monday to Friday) add 1 to the day counter
'----------------------------------------------------------------
If WeekDay(dtNextDate, vbMonday) <= 5 Then
intDayCount = intDayCount + 1
End If
dtNextDate = dtNextDate + 1
Loop
'------------------------------------------------------------------
'- Return number of business days between the start and end dates -
'------------------------------------------------------------------
BusinessDays = intDayCount
End If
End Function
Copy this code into a module, and try it manually via the Debug window. Example (NB I am using European date format dd/mm/yyyy here) - type:
? BusinessDays("01/10/2004", "10/10/2004")
The function should return '6' - there are six business days between 1 October and 10 October 2004 - including 1 October itself.
Use this function in your calculated query column:
BusinessDays([DateSubmit],[DateStarted])
This should give you the result which you need.
Bob Stubbs