none
users active for last 10 minutes RRS feed

  • Question

  • In table aspnet_Users I have column LastActivityDate - how can I get active users (last 10 minutes) ?
    Saturday, June 25, 2011 7:40 AM

Answers

  • Hi green_green;

    The following code snippet should give you what you need.

    DateTime dtEnd = DateTime.Now;
    DateTime dtStart = dtEnd.AddMinutes(-10);
    
    var results = from u in ObjectContext.aspnet_Users
           where u.LastActivityDate >= dtStart && u.LastActivityDate <= dtEnd
           select u;
    

     


    Fernando

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Saturday, June 25, 2011 3:16 PM

All replies

  • Hi,

    Since this is an ASP.NET related question, i suggest you post your questions at http://forums.asp.net which is the asp.net related forum, and have more experience with the ASP.NET membership system.

     


    --Rune
    Saturday, June 25, 2011 11:22 AM
  • But I need only get users which LastActivityDate is > than (current time - 10 minutes).
    Saturday, June 25, 2011 12:58 PM
  • Hi green_green;

    The following code snippet should give you what you need.

    DateTime dtEnd = DateTime.Now;
    DateTime dtStart = dtEnd.AddMinutes(-10);
    
    var results = from u in ObjectContext.aspnet_Users
           where u.LastActivityDate >= dtStart && u.LastActivityDate <= dtEnd
           select u;
    

     


    Fernando

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Saturday, June 25, 2011 3:16 PM
  • Again, this is an asp.net related question, where you will get answer a lot quicker on asp.net related questions.

    Are you using Entity Framework? If so, you could do something like:

    DateTime filterDate = DateTime.Now.Subtract(new TimeSpan(0, 10, 0));
    
    var result = context.aspnet_Users.Where(row => row.LastActivityDate > filterDate).ToList();
    

    And you will get your list.


    --Rune
    Saturday, June 25, 2011 3:18 PM
  • Hi green_green;

    Did the solution I posted solve your issue. If so please mark it as the solution and if it was helpful also vote that it was helpful

    Thanks


    Fernando

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Saturday, July 2, 2011 7:32 PM