I have System.DateTime.Now stored in a variable called StartDate (variable is of type DateTime?).
I am converting it to string as below:
string temp = StartDate.Value.ToString("yyyy-MM-dd HH:mm:ss")
Now the temp has value in "yyyy-MM-dd HH:mm:ss".
Now I want to again convert string temp to DateTime so, I am doing as below:
DateTime.ParseExact(temp,"yyyy-MM-dd HH:mm:ss",null)
but this doesn't work.
It always returns date in a same format as System.DatTime.Now. It should return value in "yyyy-MM-dd HH:mm:ss" format.