how to convert string format date into date format using c sharp.
Code as follows;
string[] datecheck;
string dates = "";
datecheck = dates.Split(',');
from the above date in the string format, i am converting string format date into date format for that code as follows;
string[] datecheck;
string dates = "";
string[] Coursecheck;
datecheck = dates.Split(',');
string dt = Convert.ToDateTime(dates).ToString("ddMMyyyy");
Coursecheck = PKGMinorCode.Split(',');
int len = datecheck.Length;
for (int z = 0; z < len-1; z++)
{
for (int j = z + 1; j < len-1 ; j++)
{
if (Coursecheck[z] == "ARPA" && Coursecheck[j] == "ROC")
{
if (datecheck[z] < datecheck[j])
{
ScriptManager.RegisterStartupScript(this, GetType(), "Invalid date", "alert('ROC Date is greater than the ARPA Date')", true);
return;
}
}
}
}
when i run the above code shows errors as follows;
operator '<' cannot be applied to operands of type string
the above error shows in the below line as follows;
if (datecheck[z] < datecheck[j]).
please help me. what is the problem in my above code.
Regards,
Narasiman P