Doug,
Pardon me for jumping in - but I don't see a followup response on this.
DonD,
You should probably have a table that is linked to your current table. The
table would be something like
ContractActionDates
ContractID
ActionDate
ActionType - Values such as (Sent To; Approved; etc) or better, in my opinion)
an additional table that would contain the Types of contracting actions.
ContractActionTypes
ActionID
ActionDescription
If you must live with your current design, one method that would work would be
to use a normalizing union query.
SELECT ContractID, To_Contracting as AllDates
FROM YourTable
UNION ALL
SELECT ContractID, Approved_Contracting
FROM YourTable
SELECT ContractID, ...
Save that as your source query - qNormalledDates
Then you can do the following totals query
SELECT q.ContractID,
Max(q.AllDates) as Latest,
Min(q.AllDates) as Earliest,
DateDiff("D",Min(q.AllDates),Max(q.AllDates)) as Elapsed
FROM qNormalledDates
GROUP BY q.ContractID
Another method is to use a function to get the Max and Min dates from the fields
in the row. Something like this old one I threw together. You should be able
to modify this to get a minimum across your rows.
'------------- Code Starts --------------
Public Function fGetMaxNumber(ParamArray Values()) As Variant
'John Spencer UMBC CHPDM
'Last Update: April 5, 2000
'Returns the Maximum Number of a group of values passed to it.
'Sample call: myMax = GetMaxNumber("-21","TEST","2", "3",4,5,6,"7",0) returns 7
'Ignores values that cannot be treated as numbers.
Dim i As Integer, vMax As Variant, tfFound As Boolean, dblCompare As Double
vMax = -1E+308 'very large negative number
For i = LBound(Values) To UBound(Values)
If IsNumeric(Values(i)) Then
dblCompare = CDbl(Values(i))
If dblCompare > vMax Then
vMax = dblCompare
tfFound = True
End If
End If
Next
If tfFound Then
fGetMaxNumber = vMax
Else
fGetMaxNumber = Null
End If
End Function
DonD wrote:
Thanks Doug - I'll look further into link you provided about Workdays.
I'm aware of the Datediff function. I currently use it to calculate the
difference between [To_contracting] and [Approved_contracting]. Problem is
searching across fields to find the minimum and maximum values from all date
fields to calculate the maximum time for processing.
Based on similar postings to this group, most folks will say this is a
normalization problem. But I'm not sure how I would construct the tables
differently.
:
1) There's a DateDiff function. Check the help file.
2) Not built into Access, but check
http://www.mvps.org/access/datetime/date0012.htm at "The Access Web" for one
approach.
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
1)have six dates in a table to facilitate tracking of time it takes to get
from one step to another. Sometimes event does not always progress in a
specific order. Hence, I would like to add an expression to a query that
gives me the date difference between the minimum and maximum date values.
ALSO
2) Is there a "Work Days" function in Access (like Excel) that excludes
holidays and weekends?