Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.

Active users who didn't login for X days report


Any idea how can I execute a report (or SQL query)of all users who are active but didn’t login to the system in the last x days?

Best Regards


See this thread - it is not easy to determine especially since if folks don’t log off TR - they are still active even if the browser is closed:


Hi BGanger,
I realized that it’s not easy, I wonder why is that.
How am I supposed maintain user list ? :disappointed:




SELECT,FROM_UNIXTIME(user_logins.updated_on) as’last_login’ FROM users INNER JOIN user_logins ON ( = WHERE users.is_active = 1 AND FROM_UNIXTIME(user_logins.updated_on) < ‘2018-03-01 00:00:00’;

will return in my case : lastlogin

I hope this query will help you :grin:


I wish I knew why - maybe a vestige of an old system TR is based on? They do use Unix time so maybe how Unix handles sessions vs web? It is frustrating and any query is going to be… misleading. My production table has my last session as 3/6/2018 yet I have been using TR everyday for the past 2 weeks including today.


Hi Afaeld ,
After days of use, your does bring all users who didn’t login after certain date but the “last_login” date is not correct.
Tried to fix it but with no success.
I used this query to see all login in the system and asked a colleague to preform login.
that didn’t reflect on any attribute

SELECT,,u.is_active,FROM_UNIXTIME(ul.updated_on) ,FROM_UNIXTIME(ul.created_on),FROM_UNIXTIME(ut.expires_on),FROM_UNIXTIME(ut.created_on) FROM testrail.users as u
left join user_tokens as ut
ON = ut.user_id
left join user_logins as ul
where u.is_active=1;