Sorry for my english, this is very bad.
private void loadDetalle()
{
DateTime today = DateTime.Today;
string todayS = today.ToString("yyyy/MM/dd");
DateTime fechaComparativa = DateTime.Today.AddDays(-30);
string fechaComparativaS = fechaComparativa.ToString("yyyy/MM/dd");
string queryDetalle30DiasIngresos = "select SUM(monto) from finanzas.ingresos WHERE fecha between " + fechaComparativaS + "and" + todayS;
executeQueryDetalle(labelIngreso30, queryDetalle30DiasIngresos);
}
private void executeQueryDetalle(Label Detalle, string query)
{
try
{
mcon.Open();
mcd = new MySqlCommand(query, mcon);
object result = mcd.ExecuteScalar();
Detalle.Text = Convert.ToString(result);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
mcon.Close();
}
}
And the problem with this is this:
You have a error in your SQL syntax, check the manual that corresponds to your MYSQL server version for the right syntax to use near '' at line 1