How to convert date format to dd/MM/yyyy in Linq to Sql select Query

I tried as below:

DataTable dt = Common.dc.TblMaintenances.Where(a => a.ContractId == Id && a.IsScheduled == true || a.IsScheduled == false).OrderBy(a => a.ScheduledDate).Select(a => new { a.MaintenanceId, a.MaintenanceDate.ToString("dd.MM.yy"), a.MaintenancePerson,a.Remarks,a.ScheduledDate,a.IsScheduled,a.Cost }).getDataTable();

But didn't work

What does "didn't work" mean? What results did this code give you?

I am not experienced with ASP, but I am experienced in SQL. I know that you can convert a datetime stamp in MSSQL with convert(). So, this may be helpful for what you are trying to do http://msdn.microsoft.com/en-us/library/ms187928.aspx

I use it on my MSSQL queries because the time stamp is in datetime format, so I use that at convert it to a different format.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.