List:General Discussion« Previous MessageNext Message »
From:Claudio Nanni Date:April 1 2009 3:19pm
Subject:Re: Total logged in time
View as plain text  
Just a hint:

Given the user 'User' and given no missing login/logout event logging you
can retrieve the total amount in seconds he was logged on with the following


(SELECT SUM(time_to_sec(time_stamp)) as logoutTime from logevents where
event='logout' and userid='User' )


(SELECT SUM(time_to_sec(time_stamp)) as loginTime from logevents where
event='login' and userid='User')

this can surely be developed with grouping by user and filtering by time,
this is just the basic function.

2009/4/1 Tom Scheper <scheper@stripped>

> Hi,
> I have a table like so
> id autoinc
> userid int
> action enum ('login', 'logout' )
> timestamp
> --
> Is it possible to perform a mysql query that gets the total logged in
> time for any one user on any one particular day/week/month? And how?
> --
> MySQL General Mailing List
> For list archives:
> To unsubscribe:

Total logged in timeTom Scheper1 Apr
  • Re: Total logged in timeClaudio Nanni1 Apr