如何获得登录和退出时间之间的小时和小时差异?
我使用了以下查询:
select LoginDateTime,LogoutDateTime from Fleet_DriverQueueList
我在下面附上了我的数据截图。
答案 0 :(得分:1)
尝试以下方法:
SELECT ISNULL(DATEDIFF(HOUR, LoginDateTime, LogoutDateTime), 1) FROM Table
答案 1 :(得分:1)
只需使用DATEDIFF功能即可。像这样:
SELECT
DATEDIFF(HOUR,[LoginDateTime],[LogoutDateTime])
FROM
YourTable
答案 2 :(得分:0)
最好在几分钟甚至几秒钟内使用DATEDIFF,这样会更准确:
new Handler().post(new Runnable() {
public void run() {
ItemsFragment itemsFragment = new ItemsFragment () {GroupID = groupID, CurrentGroup = currentGroup};
itemsFragment.RetainInstance = true;
var fragmentManager = SupportFragmentManager.BeginTransaction ();
fragmentManager.Replace (Resource.Id.flContent, (SupportFragment) itemsFragment);
fragmentManager.AddToBackStack (null);
fragmentManager.Commit ();
}
});
答案 3 :(得分:0)
你可以使用Datediff功能,试试这个
Select Case when isnull(LogoutDateTime,'')='' then 'Active' else 'Not Active' end as Status,
Case when isnull(LogoutDateTime,'')=''
then DATEDIFF(HH,LoginDateTime,getdate())
else DATEDIFF(HH,LoginDateTime,LogoutDateTime) end as Period
from Fleet_DriverQueueList