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

Piyush PansuriyaRank #454 · 5.5K reputationPosted Feb 4, 2015, 8:42 PM EST
string query = "select AttendanceDate from AttendanceTable where AttendanceDate=CONVERT(DATE,GETDATE())"
Sheffer Fernandes15 reputationPosted Feb 5, 2015, 5:09 AM EST
Khargesh RajputRank #616 · 3.9K reputationPosted Feb 5, 2015, 5:53 PM EST
Sheffer Fernandes15 reputationPosted Feb 6, 2015, 6:00 AM EST
Khargesh RajputRank #616 · 3.9K reputationPosted Feb 6, 2015, 6:09 PM EST
you can use like
string query = "select AttendanceDate from AttendanceTable WHERE
Format(AttendanceDate, "Short Date") = format(DATE()
, "Short Date")";