如何使用Linq to Sql将日期格式转换为dd / MM / yyyy [英] How to convert date format to dd/MM/yyyy using Linq to Sql

查看:111
本文介绍了如何使用Linq to Sql将日期格式转换为dd / MM / yyyy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆