I have 4 columns in my database
UserName, Date, Time, LoginType
UserName is a varchar field
Date is a date field
Time is a time field (in 24 hour format)
LoginType is a varchar field
LoginType can contain one of the two strings “LOGIN”, “SHUTDOWN”
I want to get the average time someone will LOGIN or SHUTDOWN
I also want to know the delta of the lateless, earliness.
So for this example, lets assume that students must attent class by 8:30 and must LOGOFF by 10:30
So lets also assume the sample data is as follows
George.Lucas 8:45 2011-07-22 LOGIN
Eric.TheRed 9:00 2011-07-22 LOGIN
Dr.Who 9:01 2011-07-22 LOGIN
Dr.Who 11:01 2011-07-22 SHUTDOWN
George.Lucas 11:45 2011-07-22 SHUTDOWN
Eric.TheRed 12:00 2011-07-22 SHUTDOWN
- We can see that George was 15 min late and he shutdown 1hr 15min late
- Eric was 30 min late to login
- Eric was 2hr 30 min late to SHUTDOWN
- Dr.Who was 31 min late LOGIN
- Dr.Who was 31 min late SHUTDOWN
Thanks
This will give you the average time a given user took between login and shutdown, even when there are multiple sessions for the same day, and assuming the user needs to shutdown before logging in again:
To find out the difference between the expected and effective login/shutdown time, you just need to subtract 8:30 and 10:30 from
login.Timeandshutdown.Time, respectively.