Easy way to check lastlogin date for all users

ejeong
All-Star
All-Star

Could anyone explain me a way to export last login date for all users? by looking audit table, its taking too much time to query for all users..

 

6 REPLIES 6

dgandhi
All-Star
All-Star

Hi @ejeong 

Below queries should give you desired output. Check userlogins table.

dgandhi_0-1684286986694.png

Thanks

 

Thanks,
Devang Gandhi
If this reply answered your question, please click the Accept As Solution button to help future users who may have a similar problem.

I couldnt use this query it's taking very long time in our envrionment. 

don't you face any issue when querying all users with this query?

I didn't execute this in Prod so don't know about timing. But yes you can limit the output by adding some condition in the where clause.

Thanks

Thanks,
Devang Gandhi
If this reply answered your question, please click the Accept As Solution button to help future users who may have a similar problem.

rushikeshvartak
All-Star
All-Star

select u.username,ul.logintime,ul.logoutdate from users u left join userlogins ul on u.userkey=ul.userkey group by ul.userkey order by ul.logintime desc

@rushikeshvartak 

I tried to create report with query provided 

but its taking long time as mentioned.

 

ejeong_0-1684294461382.png

 

Last 30 days 

select u.username,ul.logintime,ul.logoutdate from users u left join userlogins ul on u.userkey=ul.userkey
and ul.logintime BETWEEN CURDATE() - INTERVAL 30 DAY AND CURDATE()

group by ul.userkey order by ul.logintime desc