Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / August 2006

Tip: Looking for answers? Try searching our database.

Min and Max date

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rudi - 15 Aug 2006 20:57 GMT
Hi.

I have a table named "Log" that stores: RecordID (AutoNumber),
LogInTime (Date), LogOutTime (Date). I have a form named "LogIn" that I
run (with an AutoExec macro) every time the application starts. It
collects the LogInTime and stays open (invisible) so that it records
the LogOutTime when the user closes the application. This form fills my
Log table.

Now I would like to create a query that would sort the data from the
Log table. I want the query to display the first and the last LogIn and
LogOutTime for each day.

So if the Log table records look something like this:

RecordID I       LogInTime        I      LogOutTime
     1        14.8.2006 10:03:11   14.8.2006 12:33:23
     2        14.8.2006 13:01:01   14:8:2006 16:30:00
     3        15.8.2006 10:05:04   15.8.2006 15:44:35
     4        16.8.2006 10:32:44   16.8.2006 14:22:23
     5        16.8.2006 15:03:11   16.8.2006 17:02:22

I want the query to display:

MinLogInTime         I     MaxLogOutTime        I   Hours
14.8.2006 10:03:11    14.8.2006 16:30:00           6
15.8.2006 10:05:04    15.8.2006 15:44:35           5,5
16.8.2006 10:32:44    16.8.2006 17:02:22           6,5

Can anyone please help me to make this work?

Regards,

Rudi
John Spencer - 15 Aug 2006 21:23 GMT
SELECT DateValue(LoginTime) as TheDate
, Min(LoginTime) as LogStart
, Max(LogoutTime) as LogEnd
, DateDiff("n",Min(LoginTime),Max(LogoutTime)) as ElapsedMinutes
, DateDiff("n",Min(LoginTime),Max(LogoutTime)) / 60 as ElapsedHours
FROM YourTable
GROUP BY DateValue(LoginTime)

> Hi.
>
[quoted text clipped - 30 lines]
>
> Rudi
Rudi - 15 Aug 2006 21:54 GMT
Thank you very much! :)

John Spencer je napisal:
> SELECT DateValue(LoginTime) as TheDate
> , Min(LoginTime) as LogStart
[quoted text clipped - 38 lines]
> >
> > Rudi
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.