See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.FormatException: String was not recognized as a valid DateTime.
at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
at System.Convert.ToDateTime(String value)
at ExtraTutoManager.Dashcont.CulcPay(DateTime dateAf) in D:\coure du soire gestion\visual studio project\ExtraTutoManager\ExtraTutoManage
declaration global
public DateTime rendVous;
public DateTime temp;
I want to covert string to datetime by ToDateTime() , in my project VS running without any problem but in another pc this String was not recognized as a valid DateTime
temp = Convert.ToDateTime("" + dateAf.Date.Day + "/" + (DateTime.Now.Month + 1) + "/" + DateTime.Now.Year);
this is my method
//Culcs
public DateTime Culcdate(DateTime dateAf)
{
int mont = DateTime.Now.Month - dateAf.Date.Month;
if (DateTime.Now.Month == dateAf.Date.Month)
{
temp = Convert.ToDateTime("" + dateAf.Date.Day + "/" + (DateTime.Now.Month + 1) + "/" + DateTime.Now.Year);
}
else if (mont - (mont - 1) >= 1 && DateTime.Now.Day >= dateAf.Date.Day)
{
temp = Convert.ToDateTime("" + dateAf.Date.Day + "/" + (DateTime.Now.Month + 1) + "/" + DateTime.Now.Year);
}
else if (mont - (mont - 1) >= 1)
{
temp = Convert.ToDateTime("" + dateAf.Date.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year);
}
return rendVous = temp;
}