guy plz help me in comparing currentdate from db using if statement.
my error is dat nothungnis happening after button click
code:
{
connect.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connect;
string query = "select AttendanceDate from AttendanceTable where AttendanceDate=Date()";
command.CommandText = query;
OleDbDataReader reader = command.ExecuteReader();
while (reader.Read())
{
// string workername = reader["WorkerName"].ToString();
string AttDate = reader["AttendanceDate"].ToString();
string date=DateTime.Now.ToString("yyyy/MM/dd");
if(AttDate==date)
{
MessageBox.Show("hi");
}
}
connect.Close();
}
Loading
Khargesh RajputPosted Feb 6, 2015, 11:09 PM
you can use like
string query = "select AttendanceDate from AttendanceTable WHERE
Format(AttendanceDate, "Short Date") = format(DATE()
, "Short Date")";
Sheffer FernandesPosted Feb 6, 2015, 11:00 AM
Khargesh RajputPosted Feb 5, 2015, 10:53 PM
Sheffer FernandesPosted Feb 5, 2015, 10:09 AM
Piyush PansuriyaPosted Feb 5, 2015, 1:42 AM
string query = "select AttendanceDate from AttendanceTable where AttendanceDate=CONVERT(DATE,GETDATE())"