最小和最大进出时间员工 [英] Min and Max In and out time Employee
问题描述
您好,
i上传emp.accdb文件,即Microsoft Office Access 2007数据库。
然后我正在读取数据。但是我为特定用户和日期获取最小和最大日期
我如何获得最小和最大日期特定用户和日期
我的代码:
public void oldbconnction()
{
OleDbConnection conn = new OleDbConnection(oldbconnstring);
string sql = SELECT Min(LoginDate)as Intime,Max(LoginDate)as OutTime,UserID FROM tblEmployee group by LoginDate;
OleDbCommand cmd = new OleDbCommand(sql,conn);
conn.Open();
OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
adapter.Fill(results);
if (results.Rows.Count > 0 )
{
for ( int insertdata = 0 ; insertdata < results.Rows.Count; insertdata ++)
{
// 插入sql server max和min登录日期userid
Insertsql(转换.ToDateTime(results.Rows [insertdata] [ Intime]。ToString()),转换。 ToDateTime(results.Rows [insertdata] [ OutTime]。ToString()),Convert.ToInt32 (results.Rows [insertdata] [ UserID]。ToString()));
SendToZoloUrl(results.Rows [insertdata] [ Intime]。ToString(), results.Rows [insertdata] [ OutTime]。ToString(),Convert.ToInt32(结果。行[insertdata] [ UserID]。ToString()));
}
}
}
plz帮助我如何获取数据最小和最大日期时间特定用户和日期
我的emplyeedata是:
LoginDate UserID
7/17/2014 5:22:04 PM 1
7/17/2014 5:41:59 PM 1
8/12/2014 5:41:59 PM 2
8/12/2014 8:41:59 PM 2
9/17/2014 3:41:59 PM 4
这样的东西(你应该使用参数):
SELECT min(LoginDate) as minlog,max(LoginDate) as maxlog
FROM tblEmployee 其中 UserID = 1 和 LoginDate BETWEEN #2014/17/07# AND #2014/18/07#;
它选择用户ID 1和日期17 th 2014年7月的最小和最大登录日期。
引用:我可以获得具体日期2014年7月17日。最长时间吗?
[更新]
<前lang = sql> SELECT TimeValue(min(LoginDate)) as minlog,TimeValue(max(LoginDate)) as maxlog
FROM tblEmployee 其中 UserID = 1 和 LoginDate BETWEEN #2014/17/07# AND #2014/18/07#;
[/ update]
Hello ,
i am uploading emp.accdb file which is Microsoft Office Access 2007 Database.
then i am reading data .but i canot get min and max logdate for particular user and date
how can i get min and max date particular user and date
my code:
public void oldbconnction()
{
OleDbConnection conn = new OleDbConnection(oldbconnstring);
string sql = "SELECT Min(LoginDate) as Intime ,Max(LoginDate) as OutTime,UserID FROM tblEmployee group by LoginDate ";
OleDbCommand cmd = new OleDbCommand(sql, conn);
conn.Open();
OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
adapter.Fill(results);
if (results.Rows.Count > 0)
{
for (int insertdata = 0; insertdata < results.Rows.Count; insertdata++)
{
//insert into sql server max and min login date userid
Insertsql(Convert.ToDateTime(results.Rows[insertdata]["Intime"].ToString()), Convert.ToDateTime(results.Rows[insertdata]["OutTime"].ToString()), Convert.ToInt32(results.Rows[insertdata]["UserID"].ToString()));
SendToZoloUrl(results.Rows[insertdata]["Intime"].ToString(), results.Rows[insertdata]["OutTime"].ToString(),Convert.ToInt32(results.Rows[insertdata]["UserID"].ToString()));
}
}
}
plz help me how can i get data min and max datetime particular user and date
my emplyeedata is:
LoginDate UserID
7/17/2014 5:22:04 PM 1
7/17/2014 5:41:59 PM 1
8/12/2014 5:41:59 PM 2
8/12/2014 8:41:59 PM 2
9/17/2014 3:41:59 PM 4
Something like this (you should use parameters, though):
SELECT min(LoginDate) as minlog, max(LoginDate) as maxlog FROM tblEmployee where UserID=1 and LoginDate BETWEEN #2014/17/07# AND #2014/18/07#;
It selects min and max login date for UserID 1 and date 17th Jul 2014.
Quote:can i get particular date 17th Jul 2014.min and max time?
[update]
SELECT TimeValue(min(LoginDate)) as minlog, TimeValue(max(LoginDate)) as maxlog FROM tblEmployee where UserID=1 and LoginDate BETWEEN #2014/17/07# AND #2014/18/07#;
[/update]
这篇关于最小和最大进出时间员工的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!