I have a large dataset consisting of start- and endtimes of personel shifts.
I'd like to make a query that calculates the number of shifts per time period.
I used to perform this task in Excel using sumpruduct or array formulas quite
easily, but I can't figure out a way to to the same in Access.
Is it possible?
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/201001/1
|
|
0
|
|
|
|
Reply
|
bertusavius
|
1/25/2010 8:38:25 PM |
|
Post sample data with table and field names plus datatype.
--
Build a little, test a little.
"bertusavius via AccessMonster.com" wrote:
> I have a large dataset consisting of start- and endtimes of personel shifts.
> I'd like to make a query that calculates the number of shifts per time period.
>
>
> I used to perform this task in Excel using sumpruduct or array formulas quite
> easily, but I can't figure out a way to to the same in Access.
>
> Is it possible?
>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/201001/1
>
> .
>
|
|
0
|
|
|
|
Reply
|
Utf
|
1/25/2010 11:37:02 PM
|
|
One table, three columns:
id (autonr) , start time(time/date), end time(time/date)
The preferred ouput would be something like this:
time periode, nr of shifts
ie:
07:00-08:00, 5
08:00;09:00, 8
etc
--
Message posted via http://www.accessmonster.com
|
|
0
|
|
|
|
Reply
|
bertusavius
|
1/26/2010 9:57:47 AM
|
|
I do not follow your logic. A shift is only one hour long?
Are do you want all start to end time periods broken down into one hour
increments and then total that?
Post sample data and then example of what that data should produce.
--
Build a little, test a little.
"bertusavius via AccessMonster.com" wrote:
> One table, three columns:
>
> id (autonr) , start time(time/date), end time(time/date)
>
> The preferred ouput would be something like this:
>
> time periode, nr of shifts
>
> ie:
> 07:00-08:00, 5
> 08:00;09:00, 8
> etc
>
> --
> Message posted via http://www.accessmonster.com
>
> .
>
|
|
0
|
|
|
|
Reply
|
Utf
|
1/26/2010 3:33:01 PM
|
|
table of shifts:
id, shiftstart, shiftend
1, 10:00, 19:00
2, 11:00, 20:00
3, 13:00, 15:00
desired query output
timeframe, nr of active shifts
1100-1200, 2
1200-1300, 2
1300-1400, 3
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/201001/1
|
|
0
|
|
|
|
Reply
|
bertusavius
|
1/26/2010 5:34:41 PM
|
|
Based on your input data this is the results --
1100 - 1200 1200 - 1300 1300 - 1400
2 3 3
All 3 include 1300 as 13:00, 15:00 also encompasses 1300.
SELECT Sum(IIf([shiftstart]<=#12/30/1899 12:0:0# And [shiftend]>=#12/30/1899
11:0:0#,1,0)) AS [1100 - 1200], Sum(IIf([shiftstart]<=#12/30/1899 13:0:0# And
[shiftend]>=#12/30/1899#,1,0)) AS [1200 - 1300],
Sum(IIf([shiftstart]<=#12/30/1899 14:0:0# And [shiftend]>=#12/30/1899
13:0:0#,1,0)) AS [1300 - 1400]
FROM Shifts;
--
Build a little, test a little.
"bertusavius via AccessMonster.com" wrote:
> table of shifts:
>
> id, shiftstart, shiftend
> 1, 10:00, 19:00
> 2, 11:00, 20:00
> 3, 13:00, 15:00
>
>
> desired query output
>
> timeframe, nr of active shifts
> 1100-1200, 2
> 1200-1300, 2
> 1300-1400, 3
>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/201001/1
>
> .
>
|
|
0
|
|
|
|
Reply
|
Utf
|
1/26/2010 6:36:01 PM
|
|
That's spot on.
Of course you are right about the different results.
Many thanks!
--
Message posted via http://www.accessmonster.com
|
|
0
|
|
|
|
Reply
|
bertusavius
|
1/26/2010 8:12:27 PM
|
|
I would like to add another dimension to this query:
my table table now has an added colulumn DATE:
id, shiftstart, shiftend, DATE
1, 10:00, 19:00, 1-1-2010
2, 11:00, 20:00, 1-1-2010
3, 13:00, 15:00, 2-1-2010
Karl Dewey's query result looks like this (without the extra column):
1100 - 1200 1200 - 1300 1300 - 1400
2 3 3
I'd like to archieve a result like this (or similar):
1100 - 1200 1200 - 1300 1300 - 1400
1-1-2010 2 3 3
2-1-2010 0 1 1
Is this possible?
--
Message posted via http://www.accessmonster.com
|
|
0
|
|
|
|
Reply
|
bertusavius
|
2/8/2010 9:08:08 PM
|
|
First, rename your field. Date is a reserved word, and you should never use
reserved words for your own purposes. For a comprehensive list of names to
avoid (as well as a link to a free utility to check your application for
compliance), check what Allen Browne has at
http://www.allenbrowne.com/AppIssueBadWord.html
Assuming you rename it to shiftdate, try
SELECT shiftdate, Sum(IIf([shiftstart]<=#12/30/1899 12:0:0# And
[shiftend]>=#12/30/1899
11:0:0#,1,0)) AS [1100 - 1200], Sum(IIf([shiftstart]<=#12/30/1899 13:0:0#
And
[shiftend]>=#12/30/1899#,1,0)) AS [1200 - 1300],
Sum(IIf([shiftstart]<=#12/30/1899 14:0:0# And [shiftend]>=#12/30/1899
13:0:0#,1,0)) AS [1300 - 1400]
FROM Shifts
GROUP BY shiftdate
Realistically, though, you should be storing both date and time for
shiftstart and shiftend. In that case, you'd use
SELECT DateValue(shiftstart), Sum(IIf(TimeValue([shiftstart])<=#12/30/1899
12:0:0# And TimeValue([shiftend])>=#12/30/1899
11:0:0#,1,0)) AS [1100 - 1200], Sum(IIf(TimeValue([shiftstart])<=#12/30/1899
13:0:0# And
TimeValue([shiftend])>=#12/30/1899#,1,0)) AS [1200 - 1300],
Sum(IIf(TimeValue([shiftstart])<=#12/30/1899 14:0:0# And
TimeValue([shiftend])>=#12/30/1899
13:0:0#,1,0)) AS [1300 - 1400]
FROM Shifts
GROUP BY DateValue(shiftstart)
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
"bertusavius via AccessMonster.com" <u55174@uwe> wrote in message
news:a357d0492d63c@uwe...
>I would like to add another dimension to this query:
>
>
> my table table now has an added colulumn DATE:
>
> id, shiftstart, shiftend, DATE
> 1, 10:00, 19:00, 1-1-2010
> 2, 11:00, 20:00, 1-1-2010
> 3, 13:00, 15:00, 2-1-2010
>
> Karl Dewey's query result looks like this (without the extra column):
>
> 1100 - 1200 1200 - 1300 1300 - 1400
> 2 3 3
>
> I'd like to archieve a result like this (or similar):
>
> 1100 - 1200 1200 - 1300 1300 - 1400
> 1-1-2010 2 3 3
> 2-1-2010 0 1 1
>
>
> Is this possible?
>
> --
> Message posted via http://www.accessmonster.com
>
|
|
0
|
|
|
|
Reply
|
Douglas
|
2/8/2010 10:03:01 PM
|
|
Exactly the solution I was looking for.
Seems like I really need to learn a bit more about using expresions in
queries.
Really appreciate it.
Thanks!
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/201002/1
|
|
0
|
|
|
|
Reply
|
bertusavius
|
2/9/2010 6:53:33 PM
|
|
|
9 Replies
529 Views
(page loaded in 0.169 seconds)
Similiar Articles: calculate headcount - microsoft.public.access.queriesI have a large dataset consisting of start- and endtimes of personel shifts. I'd like to make a query that calculates the number of shifts per time ... Table / Form Design for Headcount Report - microsoft.public.access ...RE: calculate headcount Table / Form Design for Headcount Report: Debris: Microsoft Access Database Table Design: 2: 17th May 2007 06:07 PM: Template for Headcount ... work order form and report design help - microsoft.public.access ...Table / Form Design for Headcount Report - microsoft.public.access ... work order form ... application design for customer service work order ... automatically calculate and ... Can i avoid "00.00" when the result of a calculation is ...calculate headcount - microsoft.public.access.queries... 11:00, 20:00, 1-1-2010 3, 13:00, 15:00, 2-1-2010 Karl Dewey's query result ... comprehensive list of names to ... Query to list Company ID with Billing Period by number with date i ...calculate headcount - microsoft.public.access.queries... query that calculates the number of shifts per time period. ... query: my table table now has an added colulumn ... How to average values based on time period - microsoft.public ...calculate headcount - microsoft.public.access.queries How to average values based on time period - microsoft.public ... calculate headcount - microsoft.public.access ... How to Calculate Headcount Turnover Rate | eHow.comMost companies use the headcount turnover rate, or turnover rate, as a metric to assess the number of employees that leave the company based on the overall headcount ... How to Calculate an FTE Count | eHow.comHuman Resources departments use FTE rather than a worker headcount to calculate an amount of labor among full- and part-time employees. As an example, you can calculate ... Calculating Call Center Headcount | ICMI.comI suggest learning all about the basics of call center management, including how to calculate headcount. I'm biased, I admit, but the best resource I know of for learning ... Headcount - OrgChart.netHeadcount calculation is one of the most basic organizational metrics to be familiar with in an organization. How can you calculate headcount index - The Q&A wikiTake the amount of families below the poverty line and multiply it by how many people are in those families as the headcount index uses individuals not entire ... 7/28/2012 6:07:57 AM
|