473,394 Members | 1,750 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,394 software developers and data experts.

Query to flag a field based on calculated data

I have a table with numerous fields including timeIn and timeOut field.
I need to find out how many people were clocked in during each
operating hour. Can I run a query that will allow me to compare the
time and 'flag' a field (a new field for each hour) so that I can run a
count on the completed data?

Nov 13 '05 #1
7 2576
The basic answer to your question is that two events overlap if:
A starts before B ends, AND
B starts before A ends.

You need a table containing a record for each hour:
ID HourStart HourEnd
1 0:00:00 0:59:59
2 1:00:00 1:59:59
...
24 23:00:00 23:59:59

You can create a query containing both tables, with no join between them. In
the Field row, enter this calculated field:
ThisHour: ((TimeIn < HourEnd) AND (HourStart < TimeOut))
In the Criteria row, enter True
This will cause your record to repeat for every hour that it overlaps with.
You can then count the records for any hour.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Cruisemate" <cr********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
I have a table with numerous fields including timeIn and timeOut field.
I need to find out how many people were clocked in during each
operating hour. Can I run a query that will allow me to compare the
time and 'flag' a field (a new field for each hour) so that I can run a
count on the completed data?

Nov 13 '05 #2
I put that calculated field in, and no data comes up.
The original table is set up with the timein and timeout fields set as
date/time medium format.
I set up the second table with the time records as you advised also set
up as medium format (I also tried with short format)
but I'm still not getting any data.

Nov 13 '05 #3
Does your date/time field contain a date component, or only a time
component?

The format is not important, as Access stores the date/time values as
fractional numbers, where the integer part represnts the date, and the
fraction part the time of day.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Cruisemate" <cr********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I put that calculated field in, and no data comes up.
The original table is set up with the timein and timeout fields set as
date/time medium format.
I set up the second table with the time records as you advised also set
up as medium format (I also tried with short format)
but I'm still not getting any data.

Nov 13 '05 #4
When I put that calculated field into a query, no data comes up.
I have all the time fields set to short time and have made both tables
(not joined) but still no data.

Nov 13 '05 #5
The field has a date component, but that is not important to me for my
results. basically I just need to find out how many people were clocked
in during each hour of operation, date is unimportant. I tried the
above query again, and still no data.

Nov 13 '05 #6


--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Cruisemate" <cr********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
The field has a date component, but that is not important to me for my
results. basically I just need to find out how many people were clocked
in during each hour of operation, date is unimportant. I tried the
above query again, and still no data.

Nov 13 '05 #7
If your field has a date component, it won't match with the table that has
just the time component, unless we strip the date out.

Try:
TimeValue([TimeIn])
and
TimeValue([TimeOut])
in those expressions.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Cruisemate" <cr********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
The field has a date component, but that is not important to me for my
results. basically I just need to find out how many people were clocked
in during each hour of operation, date is unimportant. I tried the
above query again, and still no data.

Nov 13 '05 #8

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

Similar topics

3
by: Steve | last post by:
Form FrmRestock's recordsource is QryFrmRestock. The TransactionDate field's criteria is set ats: Forms!FrmRestock!LastXDays. LastXDays on the form is a combobox where the selections are 30, 60...
0
by: cruisemate | last post by:
I have a table with numerous fields including timeIn and timeOut field. I need to find out how many people were clocked in during each operating hour. Can I run a query that will allow me to...
9
by: Kelii | last post by:
I've been trying to get this piece to work for a few hours, but have given up. I hope someone out there can help, I think the issue is relatively straightforward, but being a novice, I'm stumped....
4
by: tweeterbot | last post by:
Hi, I am a chemical engineer trying to design a database and I am running into some trouble. My database is going to be 'processing' raw data to get the figures we need to prepare the monthly...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.