Results 1 to 9 of 9
  1. #1
    gryphin81's Avatar
    gryphin81 is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    New Jersey
    Posts
    5

    Time comparison based on date - Late Report

    Hello Everyone,

    This is my first post excuse my noobness
    My question is I have a table that gets information imported from Avaya CMS Supervisor. It provides me with the information below: Agent Name - Login Time - Logout Time - Login Date. I need to be able to perform the items below

    1. Look up an agent name (Below example "Agent 1")
    2. Look at the earliest login based on the date (Below example = 7:30AM) Note* Our agent sometimes have to login multiple times a day for various activities.
    3. Compare earliest login time to start schedule (Agent 1's start schedule is at 7:00AM so formula would be something like Login Time 7:30AM <= 7:00AM if false mark late)



    Click image for larger version. 

Name:	latereport.png 
Views:	16 
Size:	4.3 KB 
ID:	16170



    My questions are what are some good ideas to get this accomplished. Is Access the right tool. I've tried Excel but date/time calculation is a pain. Would I need a another table that had the agents and their start times listed ?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    If agents have different start times then yes a table with this datum would be good otherwise requires hard coding the variable start time. Table much better.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    gryphin81's Avatar
    gryphin81 is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    New Jersey
    Posts
    5

    SQL Qry Question

    for the response. I created an Agent Table called tblAgent that contains the Start times of all agents. I'm running into an issue that I can't solve. In Access I have the following sql statement in a query called qryLate.

    Code:
    SELECT Min(LoginTime), LoginDate
      FROM tblLogin 
      Where AgentName ='Agent 1'
    What i'm trying to do is query a table called tblLogin for the lowest/earliest login time. I also need to see what date the login took place so I've included the LoginDate column from the tbleLogin table to obtain that information. When I run the code I get an error message stating. "Your query does not include the specified expression 'LoginDate' as part of an aggregate function." If I remove ", LoginDate from the SELECT statement it works, but I need the date information to be displayed. I have xampp with mysql and tested it on a table with the same properties and information and that code works. Not sure what I'm doing wrong

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    I don't know xampp and MySQL but apparently what you want is a bit more complicated in Access.

    Aggregate functions must be used in Totals (GROUP BY) query.

    Why are date and time parts in separate fields? The time is saved as text, not date/time data type. This won't work. 10:00PM will sort before 7:30AM
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    gryphin81's Avatar
    gryphin81 is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    New Jersey
    Posts
    5
    Quote Originally Posted by June7 View Post
    I don't know xampp and MySQL but apparently what you want is a bit more complicated in Access.

    Aggregate functions must be used in Totals (GROUP BY) query.

    That expression will return the minimum time in the database, regardless of date. Is that what you really want? Why are date and time parts in separate fields?

    Can try the TOP N qualifier.
    I'll try the TOP N qualifier, not too familiar with it need to research. To answer your question I'm performing a late report on agents. The information contained within the table - tblLogin is imported from Avaya CMS Supervisor (Phone application agents login too). I need to validate if an agent logged in on time. Agents have multiple logins during the same day, so I need to use the earliest login time and compare that against their start time. Hope that explains it a little better.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    I edited my previous post but apparently you read it first.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    gryphin81's Avatar
    gryphin81 is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    New Jersey
    Posts
    5
    I'm a little confused.

    My LoginTime field is setup as a Date/Time field

    Click image for larger version. 

Name:	datatype.png 
Views:	13 
Size:	8.7 KB 
ID:	16200

    I added a login time of 10 pm to the table.
    Click image for larger version. 

Name:	10pm addition.png 
Views:	14 
Size:	18.9 KB 
ID:	16201

    When I run the below query it worked and returned 7:30:00 AM as the Min value.
    Code:
    SELECT Min(LoginTime)
      FROM tblLogin 
      Where AgentName ='Agent 1'
    I just can't seem to display the date field or any other field after I perform Min(LoginTime), I keep getting the error I initially posted.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Your first post showed the data structured and aligned as text. Did you try TOP N?

    Alternatives are nested subquery or domain aggregate.

    Review http://allenbrowne.com/subquery-01.html#TopN

    Example with DMin():

    SELECT * FROM tablename WHERE LoginTime = DMin("LoginTime", "tablename", "AgentName='" & [AgentName] & "' AND LoginDate=#" & [LoginDate] & "#");
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    gryphin81's Avatar
    gryphin81 is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    New Jersey
    Posts
    5

    Wink Resolved Updated my Access SQL

    Just wanted to thank you June7. I couldn't have made it this far without you. Your guidance has proven to be invaluable. Below is the code I used to resolve my dilemma.

    Code:
    SELECT Min(l.LoginTime), l.LOGINID, l.LOGOUTDATE
      FROM tblLogin as l
       INNER JOIN tblAgent as a
       ON a.AgentName = l.LOGINID
      Where a.AgentSchedule > l.LoginTime
      GROUP BY LOGOUT_DATE, LOGID

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 17
    Last Post: 04-18-2014, 01:35 PM
  2. Replies: 4
    Last Post: 09-30-2013, 05:29 AM
  3. Using the date to determine if something was late.
    By lyrikkmashairi in forum Access
    Replies: 3
    Last Post: 11-02-2010, 10:59 AM
  4. Late fees based on due date
    By CoachBarker in forum Queries
    Replies: 1
    Last Post: 11-01-2010, 08:31 AM
  5. Time Comparison
    By Larry819 in forum Queries
    Replies: 1
    Last Post: 06-22-2009, 09:26 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums