math - Get total time and create an average based on timestamps -


background: want use coldfusion find total time process takes taking 2 timestamps , adding of total times create average.

question: best way take 2 timestamps , find out difference in time minutes.

example:

time stamp #1:  2015-05-08 15:44:00.000 time stamp #2:  2015-05-11 08:52:00.000 

so time between above timestamps be: 2 days 6 hours 52 mins = 3,292 minutes

i want run conversion on handful of timestamp's , take total minutes , divide average.

to add more information question. 1. yes values coming db mssql. 2. going using individual time differences , showing , overall average. in loop each line have value 3,292 (converted mins or hours or days) , @ end of loop want show average of lines shown on page. let me know if need add other information.

assuming query sorted properly, should work.

totalminutes = 0; (i = 2; <= yourquery.recordcount; i++) totalminutes +=      datediff('n'     , yourquery.timestampfield[i-1]     ,yourquery.timestampfield[i]);  avgminutes = totalminutes / (yourquery.recordcount -1);   

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -