I am pulling a date out of a database and it is a varchar. However in the database it is formatted Y/M/D/. I need it to render on the front end a D/M/Y. I am bring it into Linq using Entity framework. It looks like this:
var startdateParam = new ObjectParameter(“StartDate”, typeof (string));
I then call the stored procedure:
var webinarProducts = mgr.GetWebinars(groupCodeParam, startdateParam).ToList();
I then assign it to my product list:
webinar.StartDate = startdateParam.Value.ToString();
Finally, in the cshtml file ( I am building this in MVC3) I display like this:
But when I publish the page it just formats as the wierd date inside the Data table Y/M/D.
I’ve tried to convert/parse/format this all over my code but I keep getting errors. What’s the best way to convert this to whatever date format I would like?
Use built-in parsing?
http://msdn.microsoft.com/en-us/library/w2sa9yss.aspx
Format strings here: http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
Then in the front end you can specify