Why i am unable to convert Datetime to the requiredformat
I am having my object variable declared as DateTime.
My date string is as follows
string strDate = "9999-12-31 00:00:00";
I use the below conversion
string FormatDateString(string strDate)
{
DateTime dt = DateTime.ParseExact(strDate, "yyyy-MM-ddTHH:mm:ss", DateTimeFormatInfo.InvariantInfo, DateTimeStyles.None);
return dt.ToString("yyy-MM-dd");
}
But while assigning to my object which was declared as DateTime i am getting an error if i convert it to datetime and assign i am missing the format i required so can any one tell how can i pass the one i needed to my object
I would like to pass Date to the object as "yyyy-MM-dd"