I have written a windows service which will use current date from system. I am getting error, only after installation of the service. but when i run the service in debug mode, its not giving any error and its working good. my current system date is displaying as 20 April 2016. I have tried using CultureInfo.InvariantCulture still I have the same Problem.
"String was not recognized as a valid DateTime."
string startDate = DateTime.ParseExact(TodayDate, "dd/MM/yyyy", CultureInfo.CurrentCulture)
.ToString("yyyy-MM-dd");
only this line giving error. i checked TodayDate value is in dd/MM/yyyy 20/04/2016 which is perfect.
string TodayDate = System.DateTime.Now.ToString("dd/MM/yyyy");
string startDate = DateTime.ParseExact(TodayDate, "dd/MM/yyyy", CultureInfo.CurrentCulture).ToString("yyyy-MM-dd");