我想显示用户的上次登录时间,而不是一个月内登录的时间。怎么写逻辑请分享我。 [英] I want to display the last login time of the user and no of times he login in a month. how to write the logic please share me.

查看:88
本文介绍了我想显示用户的上次登录时间,而不是一个月内登录的时间。怎么写逻辑请分享我。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想显示用户的上次登录时间,而不是一个月内登录的时间。

如何编写逻辑请分享我。



i有一个登录页面,我必须以登录用户的表格格式显示用户详细信息,没有时间登录和上次登录时间。

如何为此编写逻辑。请发送任何一个

Hi all,
I want to display the last login time of the user and no of times he login in a month.
how to write the logic please share me.

i have one login page and i have to display the user details in tabular format with login user, no of time login and last login time.
how to write logic for that. please send any one

推荐答案

这看起来像家庭主妇,所以我不会给你任何代码!



但是......这很简单:

1)添加一个LoginHistory表,用于存储用户ID和DateTime。

2)当他登录时,在LoginHistory中添加一行,记录当前的SQL服务器时间和用户ID。

3)当你需要知道摘要信息时,这是一个简单的SQL查询来获取上个月的历史记录:

This looks like homewrok, so I'll give you no code!

But...it's pretty simple:
1) Add a "LoginHistory" table which stores the user id, and a DateTime.
2) When he logs in, add a row to the LoginHistory which records the current SQL server time and the user ID.
3) When you need to know the summary info it's a simple SQL query to get the last month history:
SELECT UserID, COUNT(UserID) 
FROM LoginHistory 
WHERE LoginAt > DATEADD(mm, -1, GETDATE())
GROUP BY UserID 






你也可以用这种方式实现。



1)创建一个用于登录捕获的表。

2)使用更新的LastVisitedDate和count计算该表中每个月的单个记录。

3 )计数逻辑:您可以在登录时增加该用户的计数值。

4)LastVisitedDate逻辑:为该特定用户的每次登录更新VisitTime字段。

5)然后编写查询以获得该用户没有访问次数(Count)和lastVisitedDate。





使用这种类型的逻辑不需要将每个登录记录存储在DB中。
Hi,

You may implement in this way as well.

1) Create a table for login capturing.
2) Insert single record for every month in that table with updated LastVisitedDate and count.
3) Count Logic: you can increase count value for that user at the time of login.
4) LastVisitedDate Logic: Update VisitTime field for every login for that perticual user.
5) then write query to get that user no of visits (Count) and lastVisitedDate.


By using this type of logic no need to store each login record in DB.


这篇关于我想显示用户的上次登录时间,而不是一个月内登录的时间。怎么写逻辑请分享我。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆