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"
Loading

Madhu KPosted Feb 19, 2011, 6:24 AM
DateTime dt = DateTime.ParseExact(strDate, "yyyy-MM-dd HH:mm:ss", DateTimeFormatInfo.InvariantInfo, DateTimeStyles.None);
return dt.ToString("yyy-MM-dd");
Suthish NairPosted Feb 19, 2011, 6:18 AM
Dorababu MekaPosted Feb 19, 2011, 6:12 AM
Madhu KPosted Feb 19, 2011, 6:04 AM
Dorababu MekaPosted Feb 19, 2011, 5:58 AM
Madhu KPosted Feb 19, 2011, 5:56 AM
DateTime dt5 = DateTime.ParseExact(strDate, "yyyy-MM-dd HH:mm tt", DateTimeFormatInfo.InvariantInfo, DateTimeStyles.None);