Duane
I just got what you meant about naming a field "name", from your first
posting.
My actual field is not named name. I used that to help readers better
understand my scenario.
I guess my question is, if I have say 50 records all with different elapsed
time/Durations, How can I average (Add them together, Then divide/50) if
I'm trying to average the values BEFORE I have all 50 Duration values? It
looks as if your suggestion would try to average the elements (hrs, mins,
sec) of One duration, instead of the Aggregate. Unless it has the effect of
a 'running average'.
I'm just trying to understand.
This is my original SQL for calculating duration:
(DateDiff("n",[TimeOn],[TimeOff])\60) &
Format(DateDiff("n",[TimeOn],[TimeOff]) Mod 60,"\:00") &
Format(DateDiff("s",[TimeOn],[TimeOff]) Mod 60,"\:00") AS Duration
Tried this, gives 'Wrong number of arguments' error(with or without the
first Avg):
Avg(DateDiff("n",[TimeOn],[TimeOff])\60) &
Format(Avg(DateDiff("n",[TimeOn],[TimeOff]) Mod 60,"\:00")) &
Format(Avg(DateDiff("s",[TimeOn],[TimeOff]) Mod 60,"\:00")) AS
DurationAverage
This is looking ominous. Eventually I'll have different groups, with the
average time indicated for each group.
Thanks
Sid
Duane Hookom said:
This might not be an issue if you stored the duration of time in a numeric
field as I suggested. You are attempting to Average a text string. You might
want to try:
Format(Avg(DateDiff("n",[TimeOn],[TimeOff]) ) Mod 60,"\:00") &
Format(Avg(DateDiff("s",[TimeOn],[TimeOff])) Mod 60,"\:00"))
I'm not sure if I got the above correct but the object is to average the
value prior to formatting it.
--
Duane Hookom
MS Access MVP
Sid said:
Duane
I tried not using the Avg() on my Duration like this:
Avg(Format(DateDiff("n",[TimeOn],[TimeOff]) Mod 60,"\:00") &
Format(DateDiff("s",[TimeOn],[TimeOff]) Mod 60,"\:00")) AS DurationAvg
It gives the same error.
Sid
SELECT Table.Task, Avg(Table.Duration) AS DurationAverage
FROM Table
Group By Table.Task
ORDER BY Task;
Personally, I would not store a duration of time in a datetime field or
name
a field name.
--
Duane Hookom
MS Access MVP
I have a record set that consists of Groups, Names, and
TimeDurations like:
(hh:mm:ss)
Task1 Joe Smith 00:02:23
Task2 Steve Wells 00:04:23
Task1 Ed Wilson 00:05:12
Task2 Jane Jones 00:10:00
I simply want to average the times as follows:
Task1 00:03:48
Task2 00:07:12
SQL attempt:
SELECT Table.Task, Table.Name, Table.Duration
Avg(Table.Duration) AS DurationAverage
FROM Table
ORDER BY Task
Every syntax I have tried gives an error, "That I didn't include my
first
field name as a part of an aggregate function". The error disappears
when
I
remove my Avg( ) though. Do I need a format?
Any suggestions appreciated.
Sid