Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Meter Reading Calculation

Status
Not open for further replies.

scchas

Technical User
Nov 24, 2004
5
US
I have electric meter readings which for one meter can go like this:
10/10 99509
10/17 704
10/24 1513
The meter tops out at 100000 and then starts over so the actual difference between 1195 ((100000-99509)+ 7040. I need to calculate this for almost 20 meters and I tried using a min/max difference but this will not work when the meter rolls over.

I am stymied. I do not know how to do this with a query and thought an array might be the answer but I don't know. Any help would be greatly appreciated.
 
check wheather the previous reading was greater than the current one. If so, add the "Rollover" amt to the previous ... continue with the current (working scheme).



Of course this can give REALLY Really ReallY huge errors is there are bad entries in the readings ...






MichaelRed


 
Try converting the 2 numbers to the real scale first, then subtract them...

i.e. (val1 + 100000) - (val0 + 100000) where val1 is the value commeing AFTER val0...

this will break down if in 1 step you go over 100000, but since the meter will not show it anyway, it probably doesn't matter...

--------------------
Procrastinate Now!
 
How do you do what you are talking about. I understand the logic. How do I make a query or if it is programming do what I want? I need something along the line of

if val1 < val2, then (val1 + 100000)-va12 else val2-val1

How do I fix the first reading record as val1 and the next reading record as val2?
 
in your query:

SELECT iif(val1 < val2, val1+100000, val2-val1) As meterreading From tablename

Leslie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top