Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
Convert.ToDateTime(ds.Tables[0].Rows[i]["Timesheetdate"].ToShortDateString());

How to resolve this error:
C#
'object' does not contain a definition for 'ToShortDateString' and no extension method 'ToShortDateString' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
Posted
v2

1 solution

write like this
C#
Convert.ToDateTime(ds.Tables[0].Rows[i]["Timesheetdate"]).ToShortDateString();
 
Share this answer
 
v2
Comments
Dhritirao's 14-Mar-13 1:46am    
i tried like that i am getting this error: Cannot implicitly convert type 'string' to 'System.DateTime
Menon Santosh 14-Mar-13 9:21am    
try this
string input = Convert.ToString(ds.Tables[0].Rows[i]["Timesheetdate"]);
DateTime d;
if (DateTime.TryParseExact(input, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out d))
{
// use d
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900