How do i compare the months from database where my database records are stored in date format (12/12/2013)
Ignoring the days.
For example
This Month 12/08/2013
Next Month 12/09/2013
if both are match, i will return my true else false?
protected void renewCurrentBudget()
{
Boolean renew = true;
DateTime nextMonth;
SqlConnection conNew = new SqlConnection(ConfigurationManager.ConnectionStrings["connMSJ"].ConnectionString);
SqlCommand cmdNew = new SqlCommand("UPDATE Member SET CurrentBudget=@current WHERE Username=@username", conNew);
SqlCommand cmdToday = new SqlCommand("SELECT NextMonth FROM MonthlyBudget WHERE (Username=@username AND ThisMonth=@previousMonth)", conNew);
cmdNew.Parameters.AddWithValue("@current", getMonthlyBudget());
cmdNew.Parameters.AddWithValue("@username", Master.getUsername);
cmdToday.Parameters.AddWithValue("@username", Master.getUsername);
cmdToday.Parameters.AddWithValue("@previousMonth", DateTime.Now.AddMonths(-1).Month);
conNew.Open();
SqlDataReader dtrToday = cmdToday.ExecuteReader();
while (dtrToday.Read())
{
renew = false;
}
dtrToday.Close();
if (renew == true)
cmdNew.ExecuteNonQuery();
conNew.Close();
}
by using the parameters to compare