If i want show only this month isn't like this or different ?
string constr = ConfigurationManager.ConnectionStrings["kankonConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand())
{
string sql = "SELECT * FROM Table_special";
if (!string.IsNullOrEmpty(civilid.Text.Trim()))
{
sql += " WHERE civilsp LIKE @civilsp + '%' ";
sql += " AND (CONVERT(DATETIME,datesp2) >= DATEADD(MONTH, -1, GETDATE()))";
cmd.Parameters.AddWithValue("@civilsp", civilid.Text.Trim());
}
cmd.CommandText = sql;
cmd.Connection = con;
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
DataTable dt = new DataTable();
sda.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
}