I want to add 35 days to endA and store it in string AA and use that AA in my if statement to compare today's date and date in AA
But in the line AA = Convert.ToDateTime(enddateA).AddDays(35);
I get an error saying Cannot Convert type System.DateTime to String it works if I do it through var A = Convert.ToDateTime(enddateA).AddDays(35);
but than i cannot use it out of the scope.
string enddateA = "";
string dateNowA = "";
string AA = "";
string UPDATE_COMPLETE = String.Format("SELECT [FINAL_END_DATE] FROM [Campus6_convert].[dbo].[ACADEMICCALENDAR] where ACADEMIC_YEAR = '" + year + "' and ACADEMIC_TERM='" + academicterm + "' and ACADEMIC_SESSION='A'");
SqlCommand cmd = new SqlCommand(UPDATE_COMPLETE, con);
myReader = cmd.ExecuteReader();
while (myReader.Read())
{
enddateA = (myReader["FINAL_END_DATE"].ToString());
AA = Convert.ToDateTime(enddateA).AddDays(35);
dateNowA = DateTime.Now.ToString();
Console.WriteLine("" + AA + "");
}
myReader.Close();
cmd.ExecuteNonQuery();
cmd.Dispose();
con.Close();
if ( AA == dateNowA)
{
using (SqlConnection coe = new SqlConnection("server=fcpcdb02; database=campus6_convert; user id=""; password="";"))
{
coe.Open();
string UPDATE_COMPLETEE = String.Format("UPDATE [Campus6_convert].[dbo].[TRANSCRIPTDETAIL] SET FINAL_GRADE = 'F', REVISION_OPID='WFLOW', REVISION_DATE='" + revisiondate + "', REVISION_TIME='" + currentDateString + "' where FINAL_GRADE='I' and ACADEMIC_YEAR = '" + year + "' and ACADEMIC_TERM='" + academicterm + "' and ACADEMIC_SESSION='A'");
SqlCommand cd = new SqlCommand(UPDATE_COMPLETEE, coe);
cd.ExecuteNonQuery();
cd.Dispose();
coe.Close();
}
}