Click here to Skip to main content
16,016,669 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
C#
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:

VB
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
Posted
Updated 9-Sep-14 19:58pm
v2

1 solution

Something like this (you should use parameters, though):
SQL
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]
SQL
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]
 
Share this answer
 
v2
Comments
sadhana4 10-Sep-14 2:43am    
can i get particular date 17th Jul 2014.min and max time
CPallini 10-Sep-14 2:54am    
Yes, see my updated solution.
sadhana4 11-Sep-14 3:42am    
hello from where condition i have to check today date minus 1
how to do

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900