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 » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Sum the values between start and end date



 
 
Thread Tools Display Modes
  #1  
Old December 17th, 2009, 08:23 PM posted to microsoft.public.access.reports
instereo911 via AccessMonster.com
external usenet poster
 
Posts: 33
Default Sum the values between start and end date

Hi everyone,

I have two tables Table_POR_Final and Table_Workdays

On Table_POR_Final there are the following fields
ActualStartDate_BAInput
ActualEndDate_BAInput

and on Table_Workdays are two fields "Day" and "Workday". On this table it
shows each day (day) and if it is considered a workday (1 or 0 on Workday)

So what I want to do is say something like this

Sum the Workday values on Table_Workdays between ActualStartDate_BAInput!
Table_Por_Final and ActualEndDate_BAInput!Table_POR_Final


So example

ActualStartDate_BAInput 01/04/2010
ActualEndDate_BAInput 01/08/2010

Workdays (sum of workdays) = 5

So the query would run and sum the numbers in between 01/04 and 01/08
(1+1+1+1+1) and = 5


Is this possible... Am i approaching it wrong (seems like I am)


Thanks all

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ports/200912/1

  #2  
Old December 17th, 2009, 09:46 PM posted to microsoft.public.access.reports
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Sum the values between start and end date

On this table it shows each day (day) and if it is considered a workday (1
or 0 on Workday)
Does the 'day' field contain the name of the day like Monday?

How are the two tables related?

--
Build a little, test a little.


"instereo911 via AccessMonster.com" wrote:

Hi everyone,

I have two tables Table_POR_Final and Table_Workdays

On Table_POR_Final there are the following fields
ActualStartDate_BAInput
ActualEndDate_BAInput

and on Table_Workdays are two fields "Day" and "Workday". On this table it
shows each day (day) and if it is considered a workday (1 or 0 on Workday)

So what I want to do is say something like this

Sum the Workday values on Table_Workdays between ActualStartDate_BAInput!
Table_Por_Final and ActualEndDate_BAInput!Table_POR_Final


So example

ActualStartDate_BAInput 01/04/2010
ActualEndDate_BAInput 01/08/2010

Workdays (sum of workdays) = 5

So the query would run and sum the numbers in between 01/04 and 01/08
(1+1+1+1+1) and = 5


Is this possible... Am i approaching it wrong (seems like I am)


Thanks all

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ports/200912/1

.

  #3  
Old December 17th, 2009, 09:56 PM posted to microsoft.public.access.reports
instereo911 via AccessMonster.com
external usenet poster
 
Posts: 33
Default Sum the values between start and end date

Hi Karl,


I am not sure how to relate these tables. The day field contain a date.
example 01/01/2010, and the workday contains 1 or 0 (depending if it is a
workday that i am counting).


so table example
Day Workday
01/01/2010 0
01/02/2010 0
01/03/2010 1
etc
12/31/2010 0

The other table (Table_POR_Final) has two fields that i need to relate
(ActualStartDate_BAInput and
ActualEndDate_BAInput) which are both dates (example 01/01/2010, 01/02/2010
etc


I hope that helps.


KARL DEWEY wrote:
On this table it shows each day (day) and if it is considered a workday (1

or 0 on Workday)
Does the 'day' field contain the name of the day like Monday?

How are the two tables related?

Hi everyone,

[quoted text clipped - 25 lines]

Thanks all


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ports/200912/1

  #4  
Old December 17th, 2009, 11:53 PM posted to microsoft.public.access.reports
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Sum the values between start and end date

Try this -
SELECT Sum([Workday]) AS My_Days_Worked
FROM [Table_Workdays], Table_POR_Final
WHERE [Day] Between [ActualStartDate_BAInput] AND [ActualEndDate_BAInput];

--
Build a little, test a little.


"instereo911 via AccessMonster.com" wrote:

Hi Karl,


I am not sure how to relate these tables. The day field contain a date.
example 01/01/2010, and the workday contains 1 or 0 (depending if it is a
workday that i am counting).


so table example
Day Workday
01/01/2010 0
01/02/2010 0
01/03/2010 1
etc
12/31/2010 0

The other table (Table_POR_Final) has two fields that i need to relate
(ActualStartDate_BAInput and
ActualEndDate_BAInput) which are both dates (example 01/01/2010, 01/02/2010
etc


I hope that helps.


KARL DEWEY wrote:
On this table it shows each day (day) and if it is considered a workday (1

or 0 on Workday)
Does the 'day' field contain the name of the day like Monday?

How are the two tables related?

Hi everyone,

[quoted text clipped - 25 lines]

Thanks all


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ports/200912/1

.

  #5  
Old December 18th, 2009, 02:04 PM posted to microsoft.public.access.reports
Dale Fye
external usenet poster
 
Posts: 2,651
Default Sum the values between start and end date

I assume that Table_POR_Final contains some other fields as well, so I'll
propose a solution that includes the PK (assumed to be ID) from that table.

Select Table_POR_Final.ID, Sum([tbl_Workdays].[Workday]) as WorkdayCount
FROM Table_POR_Final, Table_Workdays
WHERE Table_Workdays.Day
BETWEEN table_POR_Final.ActualStartDate_BAInput
AND table_POR_Final.ActualEndDate_BAInput
GROUP BY Table_POR_Final.ID

----
HTH
Dale


  #6  
Old December 18th, 2009, 02:41 PM posted to microsoft.public.access.reports
John Spencer
external usenet poster
 
Posts: 7,815
Default Sum the values between start and end date

No Join solution.
SELECT ActualStartDate_BAInput
, ActualEndDate_BAInput
, Sum(W.Day.[Day]) as CountOfDays
FROM Table_POR_Final As P , Table_Workdays as W
WHERE W.[Day]=ActualStartDate_BAInput
AND W.[Day]=ActualEndDate_BAInput
GROUP BY ActualStartDate_BAInput
, ActualEndDate_BAInput

You can also do this with a NON-equi join
SELECT ActualStartDate_BAInput
, ActualEndDate_BAInput
, Sum(W.Day.[Day]) as CountOfDays
FROM Table_Workdays as W INNER JOIN Table_POR_Final As P
ON W.[Day]=ActualStartDate_BAInput
and W.[Day]=ActualEndDate_BAInput
GROUP BY ActualStartDate_BAInput
, ActualEndDate_BAInput

I'm a bit dyslexic with the greater than/less than operators and often get the
comparison backwards. If this does not work try switching the operators.


John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

instereo911 via AccessMonster.com wrote:
Hi everyone,

I have two tables Table_POR_Final and Table_Workdays

On Table_POR_Final there are the following fields
ActualStartDate_BAInput
ActualEndDate_BAInput

and on Table_Workdays are two fields "Day" and "Workday". On this table it
shows each day (day) and if it is considered a workday (1 or 0 on Workday)

So what I want to do is say something like this

Sum the Workday values on Table_Workdays between ActualStartDate_BAInput!
Table_Por_Final and ActualEndDate_BAInput!Table_POR_Final


So example

ActualStartDate_BAInput 01/04/2010
ActualEndDate_BAInput 01/08/2010

Workdays (sum of workdays) = 5

So the query would run and sum the numbers in between 01/04 and 01/08
(1+1+1+1+1) and = 5


Is this possible... Am i approaching it wrong (seems like I am)


Thanks all

 




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 03:11 AM.


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