如何使用Linq to Sql将日期格式转换为dd / MM / yyyy [英] How to convert date format to dd/MM/yyyy using Linq to Sql
问题描述
如何使用Linq到Sql将日期格式转换为dd / MM / yyyy
我尝试如下:
DataTable dt = Common.dc.TblMaintenances.Where(a => a.ContractId == Id && a.IsScheduled == true || a.IsScheduled == false).OrderBy(a => a.ScheduledDate)。选择(a = > new {a.MaintenanceId,a.MaintenanceDate.ToString(dd.MM.yy),a.MaintenancePerson,a.Remarks,a.ScheduledDate,a.IsScheduled,a.Cost})。getDataTable();
但是没有工作
嘿,对于你要找的格式,你需要使用a.MaintenanceDate.ToString( dd / MM / yyyy)
您好,
看看这里,
http://forums.asp.net/t/1698201.aspx/1 [ ^ ]
http://forums.asp.net/t /1854597.aspx/1 [ ^
How to convert date format to dd/MM/yyyy using Linq to Sql
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
Hey for the format you are looking for you will need to use a.MaintenanceDate.ToString("dd/MM/yyyy")
Hi,
Have a look here,
http://forums.asp.net/t/1698201.aspx/1[^]
http://forums.asp.net/t/1854597.aspx/1[^]
这篇关于如何使用Linq to Sql将日期格式转换为dd / MM / yyyy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!