Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Filter a query
Masih Ostad Novin 
     
3 years ago
Hi. I have this problem. I want to filter my query that has startTime and EndTime columns. I want to filter soif one of my staff members is not at work, say between 10 am and 14 pm, the query doesn't show that person during that time but displays him during the rest of the day. How can I do that? I have also watched the appointment video but couldn't find this.
Thanks for any help!
Kevin Yip  @Reply  
     
3 years ago
If the working window doesn't match 10am-14pm but *overlaps* portion of it, do you want your query to return it?

For instance, if a worker works during 13:59pm to 18pm, or 12pm-16pm, or 10:01am to 14:01pm, then technically none of these are the same window as 10am to 14pm.  

If your query doesn't accept such overlapping, then it is a much easier query to make.  You simply make a criteria where a worker's start time and end time are BOTH less than 10am *or* BOTH greater than 14pm.

But if you accept overlapping, then it will complicate matters.

Masih Ostad Novin OP  @Reply  
     
3 years ago
Thanks Kevin. The working hours are 08:00-16:00. But what I want is that if a person is absent like 10:00-12:00, just two hours. We ca forget the minutes, it's enough with hours. How can I filter this query? Later I want to make a combo based on this.
Masih Ostad Novin OP  @Reply  
     
3 years ago
OK. I tried ChatGPT and it returned this:

To filter the query in MS Access based on a person's absence for just two hours, you can use the "DateDiff" function to calculate the number of hours between the start and end time of the absence, and then use a filter to show only those records where the difference is equal to two. Here's an example query:

SELECT * FROM [your table name] WHERE DateDiff("h", [absence start time], [absence end time]) = 2;

Replace "[your table name]" with the name of the table that contains the absence data, and "[absence start time]" and "[absence end time]" with the names of the fields that contain the start and end times of each absence. This should give you a list of all the records where the absence was exactly two hours long.

I don't want to do this for a person. I want to automate this for everybody. Thanks!
Kevin Yip  @Reply  
     
3 years ago
What data does your table have about your staff, and what data do you want your query to give you?  In other words, what do you mean by "displaying your people" with the query?  I thought your table simply had your workers' daily start time and end time.  But from your description, it seems you table has a different kind of data.
Masih Ostad Novin OP  @Reply  
     
3 years ago
Thanks Kevin. I have start date and end date. For example if a person is absent between 10 am -11 am but working before after and after that time. How can I filter that?
Kevin Yip  @Reply  
     
3 years ago
Again, you need to show me what your table's fields and data look like, because what I think they are seem different from what you have.  Please show me something like:

WorkerID    StartTime    EndTime
1000        10am         14pm
1001        9am          13pm
1002        11am         16pm

The above is just an example.  Show me what your table or tables look like exactly.
Masih Ostad Novin OP  @Reply  
     
3 years ago

Masih Ostad Novin OP  @Reply  
     
3 years ago

Masih Ostad Novin OP  @Reply  
     
3 years ago
Dear kevin, here are my table and query. Thanks for helping me out.
Kevin Yip  @Reply  
     
3 years ago
I don't quite understand the need for the times of absence.  Their working hours should be enough to indicate their absence.  If I work from 9am to 5pm, it is automatically clear that my absence is 5:01pm to 8:59am, isn't it?.  Why do you need to specify absence in your table?  Also, what type of results do you want your query to return (please show me some data)?

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/6/2026 7:03:43 AM. PLT: 0s