Ask a Question related to Macromedia ColdFusion, Design and Development.
-
JoeyTMann #1
average days
I have a db with two colums create_date and finish_date. What I would like to
do is take the datediff of each row , add them togehter, then divide by number
of rows. I can get a list the datediffs for each row and I know I need to get
them into an array, then use ArrayAvg to get my result. I just can't get my
head around getting the array populated. Any tips, help, suggestions would be
nice. Thanks.
Jason
JoeyTMann Guest
-
#39560 [NEW]: Inconsistent behaviour of strtotime when days > days in month
From: php at colin dot guthr dot ie Operating system: Linux PHP version: 5.2.0 PHP Bug Type: Date/time related Bug... -
Calculating a moving average
Hi, I need to calculate a moving average and I would like to do it with SQL, or a Pg function built for this purpose. I'm on Pg 7.4. Is this... -
average using lingo
i need a huge hand with something i need to write a function to calculate the average of a sequence and return the result. however it should only... -
sar on solaris 9 does not give average
Pros, I was wondering if there is a way to get sar print the Average of CPU (Actually anything) on a Solaris 9 box? For example: On a solaris... -
Calculate Running Average
Hi everybody.I'm Facing a ploblem to calculate running average.I am explaining the scenario. In my table there are two column only 1.Name... -
Mr Black #2
Re: average days
Maybe something like this (MS SQL):
select AVG(DATEDIFF(d, create_date, finish_date)) from your_table group by key_field
Mr Black Guest
-
JoeyTMann #3
Re: average days
after banging my head against the wall for awhile I came up with...
<cfoutput>
<cfquery name="gettime" datasource="#DSN#">
select create_date,finish_date
from tickets
where assigned_to='#attributes.tech#'
and status='closed'
</cfquery>
</cfoutput>
<cfset myArray = ArrayNew(1)>
<cfloop query="gettime">
<cfset temp= arrayappend(myArray,datediff('d',create_date,finis h_date))>
</cfloop>
<cfoutput>
Average is #round(ArrayAvg(myarray))# days for #attributes.tech# to close a
tag.
</cfoutput>
which worked nicely. Not very neat, but it works.
JoeyTMann Guest
-
paross1 #4
Re: average days
Wow, you must really like doing things the hard way. What was wrong with the
suggestion by Mr Black?
select AVG(DATEDIFF(d, create_date, finish_date))
or even
select SUM(DATEDIFF(d, create_date, finish_date))/count(*)
should give you your results without all of the array stuff. Oh well...
Phil
paross1 Guest
-



Reply With Quote

