Linq DateTime Format如何使用?/转换? [英] Linq DateTime Format how to use?/Convert?
本文介绍了Linq DateTime Format如何使用?/转换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尊敬的先生,
帮助我如何转换LINQ日期时间格式
示例:
2012年1月26日,星期二,(或)
2,2012年1月26日,星期二
给我解决方法吗?
通过mohan
dear sir,
Help me how to convert LINQ datetime Format
Example:
1, Tuesday, 26 January 2012 (or)
2, Tue, 26 Jan 2012
Give me solutions?
By mohan
推荐答案
YearMonth = r.SomeDateTime.ToString("dddd, MMMM yyyy")
linq不知道转换为"ToString()"方法,因此当您正在获得像
这样可枚举的数据 var selectQuery = from db.address.asEnumerable()中的add;
那么现在您可以使用convert或"tostring"方法.
the linq doest know convert, "ToString()" methods so when you are getting the data use enumerable like
var selectQuery = from add in db.address.asEnumerable() ;
then now you can use convert or "tostring" methods.
(从time.table中的类名中选择t.Date).ToList().Select(d => d.ToString( "yyyy-MM-dd");
试试看吧.......
(from classname in time.table select t.Date).ToList().Select(d => d.ToString("yyyy-MM-dd");
try it works .......
这篇关于Linq DateTime Format如何使用?/转换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文