A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Calculation on incrementing record.



 
 
Thread Tools Display Modes
  #1  
Old January 9th, 2007, 03:24 PM posted to microsoft.public.access.queries
Phil
external usenet poster
 
Posts: 606
Default Calculation on incrementing record.

I have a probably simple question. I have a db with a usage field that
increments daily. When I query it I want to find out the difference in the
usage field between the start date in the query and the end date in the
query. In other words, what was the usage between those dates?

Thanks for any help.

Phil
  #2  
Old January 9th, 2007, 04:57 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Calculation on incrementing record.

Simplest example would be the following, assuming the Usage always
increases.

SELECT Max(Usage) - Min(Usage) as theDiff
FROM YourTable
WHERE UsageDate Between #1/1/2001# and #1/31/2001#

Sorry for the generic answer, but I didn't see many clues.
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"Phil" wrote in message
...
I have a probably simple question. I have a db with a usage field that
increments daily. When I query it I want to find out the difference in the
usage field between the start date in the query and the end date in the
query. In other words, what was the usage between those dates?

Thanks for any help.

Phil



  #3  
Old January 9th, 2007, 05:00 PM posted to microsoft.public.access.queries
Ken Sheridan
external usenet poster
 
Posts: 3,433
Default Calculation on incrementing record.

Phil:

Try something like this:

PARAMETERS
[StartDate:] DATETIME,
[EndDate:] DATETIME;
SELECT
MAX(usage) – MIN(usage) AS totalusage
FROM YourTable
WHERE usagedate = [StartDate:]
AND usagedate [EndDate:] + 1;

Ken Sheridan
Stafford, England

"Phil" wrote:

I have a probably simple question. I have a db with a usage field that
increments daily. When I query it I want to find out the difference in the
usage field between the start date in the query and the end date in the
query. In other words, what was the usage between those dates?

Thanks for any help.

Phil


  #4  
Old January 9th, 2007, 05:49 PM posted to microsoft.public.access.queries
Phil
external usenet poster
 
Posts: 606
Default Calculation on incrementing record.

Thanks John, I think that might be it, but I'm an Access newbie. Where do I
enter that code?

Phil

"John Spencer" wrote:

Simplest example would be the following, assuming the Usage always
increases.

SELECT Max(Usage) - Min(Usage) as theDiff
FROM YourTable
WHERE UsageDate Between #1/1/2001# and #1/31/2001#

Sorry for the generic answer, but I didn't see many clues.
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"Phil" wrote in message
...
I have a probably simple question. I have a db with a usage field that
increments daily. When I query it I want to find out the difference in the
usage field between the start date in the query and the end date in the
query. In other words, what was the usage between those dates?

Thanks for any help.

Phil




  #5  
Old January 9th, 2007, 08:43 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Calculation on incrementing record.

That is a query.
Open a new query in design view
Select your table
Select View: SQL from menu
Paste in the code and replace field and table names with yours
Select Query Run

If it runs you have constructed a query.

Switch back to the design window if you want to see what it looks like with
the grid.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"Phil" wrote in message
...
Thanks John, I think that might be it, but I'm an Access newbie. Where do
I
enter that code?

Phil

"John Spencer" wrote:

Simplest example would be the following, assuming the Usage always
increases.

SELECT Max(Usage) - Min(Usage) as theDiff
FROM YourTable
WHERE UsageDate Between #1/1/2001# and #1/31/2001#

Sorry for the generic answer, but I didn't see many clues.
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"Phil" wrote in message
...
I have a probably simple question. I have a db with a usage field that
increments daily. When I query it I want to find out the difference in
the
usage field between the start date in the query and the end date in the
query. In other words, what was the usage between those dates?

Thanks for any help.

Phil






  #6  
Old January 11th, 2007, 11:50 PM posted to microsoft.public.access.queries
Phil
external usenet poster
 
Posts: 606
Default Calculation on incrementing record.

Thanks John, it works. I have another issue when I add it into my existing
query, but i'll post that separately.

Phil

"John Spencer" wrote:

That is a query.
Open a new query in design view
Select your table
Select View: SQL from menu
Paste in the code and replace field and table names with yours
Select Query Run

If it runs you have constructed a query.

Switch back to the design window if you want to see what it looks like with
the grid.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"Phil" wrote in message
...
Thanks John, I think that might be it, but I'm an Access newbie. Where do
I
enter that code?

Phil

"John Spencer" wrote:

Simplest example would be the following, assuming the Usage always
increases.

SELECT Max(Usage) - Min(Usage) as theDiff
FROM YourTable
WHERE UsageDate Between #1/1/2001# and #1/31/2001#

Sorry for the generic answer, but I didn't see many clues.
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"Phil" wrote in message
...
I have a probably simple question. I have a db with a usage field that
increments daily. When I query it I want to find out the difference in
the
usage field between the start date in the query and the end date in the
query. In other words, what was the usage between those dates?

Thanks for any help.

Phil






 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:08 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.