473,378 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Averages across a certain Time Span

I have a database that stores data collected from a variety of
instruments (pressure, temperature, flow rate, etc.) everytime there
is a 1% change in the value.

The Project Manager wants to be able to take the data and generate a
report that shows a series of timed averages across a larger time
span. For example, over an eight hour time range, he wants the
instrument averages in five minute blocks.

00:00:01 - 00:05:00 Press1avg01 | Temp1avg01 | Flow1avg01 | etc...
00:05:01 - 00:10:00 Press1avg02 | Temp1avg02 | Flow1avg02 | etc...
00:10:01 - 00:15:00 Press1avg03 | Temp1avg03 | Flow1avg03 | etc...
00:15:01 - 00:20:00 Press1avg04 | Temp1avg04 | Flow1avg04 | etc...
....
07:50:01 - 07:55:00 Press1avg95 | Temp1avg95 | Flow1avg03 | etc...
07:55:01 - 08:00:00 Press1avg96 | Temp1avg96 | Flow1avg04 | etc...

The core data is stored in the following format:
Time_and_Date | InstrumentName | Value [Float]

I can handle generating an average across a single time span, but I am
a little baffled as to how to cleanly generate a sequence of average.
Especially, since the data is not logged on a specific time rate (e.g.
every five minutes), but on percent change.

Thanks in Advance,
Ken

Jun 15 '07 #1
3 2200
On 15 Jun, 06:51, ken.di...@gmail.com wrote:
I have a database that stores data collected from a variety of
instruments (pressure, temperature, flow rate, etc.) everytime there
is a 1% change in the value.

The Project Manager wants to be able to take the data and generate a
report that shows a series of timed averages across a larger time
span. For example, over an eight hour time range, he wants the
instrument averages in five minute blocks.

00:00:01 - 00:05:00 Press1avg01 | Temp1avg01 | Flow1avg01 | etc...
00:05:01 - 00:10:00 Press1avg02 | Temp1avg02 | Flow1avg02 | etc...
00:10:01 - 00:15:00 Press1avg03 | Temp1avg03 | Flow1avg03 | etc...
00:15:01 - 00:20:00 Press1avg04 | Temp1avg04 | Flow1avg04 | etc...
...
07:50:01 - 07:55:00 Press1avg95 | Temp1avg95 | Flow1avg03 | etc...
07:55:01 - 08:00:00 Press1avg96 | Temp1avg96 | Flow1avg04 | etc...

The core data is stored in the following format:
Time_and_Date | InstrumentName | Value [Float]

I can handle generating an average across a single time span, but I am
a little baffled as to how to cleanly generate a sequence of average.
Especially, since the data is not logged on a specific time rate (e.g.
every five minutes), but on percent change.

Thanks in Advance,
Ken
Hi Ken

looks complicated, have you tried using a parameter based query with a
between x and y for the time to give the time buckets?

regards, Bruce

Jun 15 '07 #2
One way is to build and populate a table of time buckets, e.g.

----------------------------------------
create table timePeriods
(
startTime datetime not null primary key,
endTime datetime not null
)
----------------------------------------

you can use something like this to populate the 5-minute increments:

-----------------------------------------
Dim sqlString As String
Dim timeFrom As Date
Dim timeTo As Date

timeFrom = 0
Do While timeTo < #8:00:00 AM#
timeTo = DateAdd("n", 5, timeFrom)
sqlString = "insert into timePeriods(startTime, endTime) " _
& "values (#" & Format$(timeFrom, "hh:mm:ss") & "#,#" _
& Format$(timeTo, "hh:mm:ss") & "#)"
CurrentProject.Connection.Execute sqlString
timeFrom = timeTo
Loop
------------------------------------------

then join to this table in your query:

------------------------------------------
select t.startTime, t.endTime, r.InstrumentName,
Avg(r.Value) as avgValue
from timePeriods as t left join readings as r
on r.Time_and_Date>=t.startTime
and r.Time_and_Date<t.endTime
group by t.startTime, t.endTime, r.InstrumentName
order by t.startTime;

------------------------------------------

The above gives the 5-minute averages for each instrument so pop that
into a crosstab query and you're set. You'll need to figure out a way to
chop off the date portion from your date_and_time column values - I'll
leave that to you :)


ke*******@gmail.com wrote:
I have a database that stores data collected from a variety of
instruments (pressure, temperature, flow rate, etc.) everytime there
is a 1% change in the value.

The Project Manager wants to be able to take the data and generate a
report that shows a series of timed averages across a larger time
span. For example, over an eight hour time range, he wants the
instrument averages in five minute blocks.

00:00:01 - 00:05:00 Press1avg01 | Temp1avg01 | Flow1avg01 | etc...
00:05:01 - 00:10:00 Press1avg02 | Temp1avg02 | Flow1avg02 | etc...
00:10:01 - 00:15:00 Press1avg03 | Temp1avg03 | Flow1avg03 | etc...
00:15:01 - 00:20:00 Press1avg04 | Temp1avg04 | Flow1avg04 | etc...
...
07:50:01 - 07:55:00 Press1avg95 | Temp1avg95 | Flow1avg03 | etc...
07:55:01 - 08:00:00 Press1avg96 | Temp1avg96 | Flow1avg04 | etc...

The core data is stored in the following format:
Time_and_Date | InstrumentName | Value [Float]

I can handle generating an average across a single time span, but I am
a little baffled as to how to cleanly generate a sequence of average.
Especially, since the data is not logged on a specific time rate (e.g.
every five minutes), but on percent change.

Thanks in Advance,
Ken
Jun 15 '07 #3
Ken,

It sounds to me that you will have to create a new table with five minute
intervals, and to populate the table you should interpolate from the values in
the old table. Not too tricky to do in code.

Hope this helps,

Gary

<ke*******@gmail.comwrote in message
news:11*********************@z28g2000prd.googlegro ups.com...
>I have a database that stores data collected from a variety of
instruments (pressure, temperature, flow rate, etc.) everytime there
is a 1% change in the value.

The Project Manager wants to be able to take the data and generate a
report that shows a series of timed averages across a larger time
span. For example, over an eight hour time range, he wants the
instrument averages in five minute blocks.

00:00:01 - 00:05:00 Press1avg01 | Temp1avg01 | Flow1avg01 | etc...
00:05:01 - 00:10:00 Press1avg02 | Temp1avg02 | Flow1avg02 | etc...
00:10:01 - 00:15:00 Press1avg03 | Temp1avg03 | Flow1avg03 | etc...
00:15:01 - 00:20:00 Press1avg04 | Temp1avg04 | Flow1avg04 | etc...
...
07:50:01 - 07:55:00 Press1avg95 | Temp1avg95 | Flow1avg03 | etc...
07:55:01 - 08:00:00 Press1avg96 | Temp1avg96 | Flow1avg04 | etc...

The core data is stored in the following format:
Time_and_Date | InstrumentName | Value [Float]

I can handle generating an average across a single time span, but I am
a little baffled as to how to cleanly generate a sequence of average.
Especially, since the data is not logged on a specific time rate (e.g.
every five minutes), but on percent change.

Thanks in Advance,
Ken

Jun 15 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jeff Blee | last post by:
I am hoping someone can help me. I am making a Access 97 app for a person and have run up against a problem to do with MS Graph. There is a table that has a number of data elements and a date field...
2
by: Stephajn Craig | last post by:
Is there a way that I can have a page do some highlighting based on a set of given keywords? The scenario is that a user does a search for certain keywords, and then the items returned have the...
9
by: McGeeky | last post by:
Is there a way to get a user control to remember its state across pages? I have a standard page layout I use with a header and footer as user controls. Each page uses the same layout by means of...
18
by: Max | last post by:
This is a follow-up on my previous thread concerning having the program wait for a certain date and time and then executing some code when it gets there. My question is; can I use the Sleep...
3
by: DotNetGuy | last post by:
I have been programming in asp.net w/ vb for 3 years now and I feel a need to include more client side script with javascript so here I am. Hopefully in the right place. I have a timecard web app...
27
by: VK | last post by:
Following the side thread about the time precision in browser at <http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/91b9f3fd90513161/1ea06131c63cfdf0?hl=en#doc_620f160f0cb57c8c>...
1
by: HockeyHero | last post by:
I have a simple table containing a datetime field and a number of data fields. I need to develop a stored procedure that will accept two dates as parameters and report back the average daily value...
1
kmartinenko
by: kmartinenko | last post by:
I have a table with over 12,000 entries. I have created a form (with the help of this forum) that will return the search results based upon the stop and stop time selected. See post...
1
by: PhilMond | last post by:
An ASP.NET page was created with VS 2003 to run on NET Framework 1.1. The code for the datagrid starts with: <asp:datagrid id="DGUnpaidInvoices" runat="server" AutoGenerateColumns="False"> and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.