Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Find personnel logged in on a given day

Posted on 2014-09-03
6
157 Views
Last Modified: 2014-09-10
I have a table that has controller login and logout times.
Format is General Date (9/3/2014 12:20:18 PM)
I am trying to design a query that asks  for a date [date?] and then returns anyone logged in that date. (between 00:00 and 23:59 that date)

Here's the catch.  
I might come to work at 8pm (LOGIN:  9/2/2014 20:00:00) and stay until 4am (LOGOUT: 9/3/2014 04:00:00).

when I get the date? prompt, I want to be able to type 9/3/2014 and have it return the login above.   Same return if I ask for 9/2.   Showing the login and logout time crossing the day.

So, for example, I get the date? prompt and type 9/2/14, I want:

Smith, 9/2/2014 08:00:00, 9/2/2014 08:00:00
Doe, 9/2/2014 20:00:00, 9/3/2014 04:00:00


and if I type 9/3/14, I also want:
Jones, 9/3/2014 09:14:00, 9/3/2014 08:00:00
Doe, 9/2/2014 20:00:00, 9/3/2014 04:00:00
0
Comment
Question by:TIgerV
6 Comments
 
LVL 5

Expert Comment

by:Jan Louwerens
ID: 40301870
Something like:

SELECT * FROM <Table> WHERE
   Login < <date_plus_1_day> AND
   Logout >= <date>
0
 

Author Comment

by:TIgerV
ID: 40301902
<date_plus_1_day>

How do I tell the query <date_plus_1_day>?
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 40301919
Or you could use something like:

SELECT * FROM yourTable
WHERE DateValue([Login]) = [Enter date (mm/dd/yy)]
OR DateValue([LogOut]) = [Enter date (mm/dd/yy)]
0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
LVL 30

Expert Comment

by:hnasr
ID: 40301957
Try:
SELECT * FROM tbl
WHERE [selectedDate] BETWEEN LOGIN AND LOGOUT
0
 
LVL 5

Expert Comment

by:Jan Louwerens
ID: 40302103
It looks like Access has a DateAdd function:
DateAdd("d", 1, <date>)

Open in new window

0
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 40303247
This should do:

SELECT *
FROM tblYourTable
WHERE [Date?] BETWEEN INT(LOGIN) AND LOGOUT

The trick is that Int cuts the time part, thus makes 9/2/2014 08:00:00 to match an input of 9/2/2014.

/gustav
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question