You need to sign in to do that
Don't have an account?
Raj R.
How would i determine if user has logged in within last 24hours?
Hi,
We have a need to schedule a batch that will perform some action if the user has not logged in in the last 24hours. On the User object, there is a LastLoginDate field which is a DateTime field.
I want to write a SOQL query that will filter out (not select) users who have logged in with last 24hours. I am having difficulty understanding the correct syntex and need help determining what would be the best approach. What would be the recommended way to do this?
The goal is to get the set of records where all user.lastlogindate >= 3/29/2017T18:05:53 and user.LastLoginDate <=3/30/2017T18:05:53 (basically within the last 24hours when the logic is ran). Any thoughts?
We have a need to schedule a batch that will perform some action if the user has not logged in in the last 24hours. On the User object, there is a LastLoginDate field which is a DateTime field.
I want to write a SOQL query that will filter out (not select) users who have logged in with last 24hours. I am having difficulty understanding the correct syntex and need help determining what would be the best approach. What would be the recommended way to do this?
/* *i tried this but it was giving very weird response. *if today = 3/30/2017, when i do the following below i see that in the debug statements that it pulling users with a lastlogindate of 2017-03-30T07:XX:XX values * if i print DateTime.Now() i am getting a result of 2017-03-31T01:05:53 (if i were to run it on 3/30/2017 6:05pm PT */ List<User> usrs = [Select Id, LastLoginDate, IsActive, Name From User Where LastLoginDate = TODAY];
The goal is to get the set of records where all user.lastlogindate >= 3/29/2017T18:05:53 and user.LastLoginDate <=3/30/2017T18:05:53 (basically within the last 24hours when the logic is ran). Any thoughts?
This query will help you fetching the users who logged in the last 24 hours (until the current minute you are running this query).
Let me know if this helps.
All Answers
Can you try this way ?
Thanks
Brahma
This query will help you fetching the users who logged in the last 24 hours (until the current minute you are running this query).
Let me know if this helps.
If the above solution doesn't satisfyies your requirement then you can use loginHistory or AuthSession syatem object to get the same info.
Regards,
GM
You can try this
datetime lastdt = System.now()-1;
List<User> t=[Select Id, LastLoginDate, IsActive, Name From User
Where LastLoginDate < :lastdt ];
Sumit Sharma
Mirketa Inc (http://www.mirketa.com/)