使用lambda表达式将datetime转换为MM yyyy,dd [英] Convert datetime to MM yyyy, dd using lambda expression
本文介绍了使用lambda表达式将datetime转换为MM yyyy,dd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将日期格式更改为MM:yyyy:dd
(2018年10月24日),我尝试了所有我知道的方法,但是它不起作用...这是我的代码(我在线上获得的许多方法之一):
I am trying to change the date format to MM:yyyy:dd
(October 2018, 24), I've tried every method I know, but it's not working... here is my code(one of many method I got online):
var data = (from o in db.tbPATxns
join p in db.providers on o.providerid equals p.providertin
join a in db.Endorsements on o.panumber equals a.panumber
join b in db.members on o.IID equals b.legacycode
join c in db.proceduredatas on a.proccode equals c.procedurecode
where c.proceduredesc.ToLower().Contains("admission")
select new
{
o.panumber,
b.legacycode,
b.lastname,
b.firstname,
b.phone1,
p.providername,
a.txndate.ToString("MMMM dd, yyyy")
});
RadGrid1.DataSource = data.ToList();
RadGrid1.DataBind();
请帮帮我.
推荐答案
字母"MM"将仅返回月份号.如果要显示月份名称,则需要使用类似以下的内容:
The letters "MM" will return only the month number. If you want to show the month name you need to use something like this:
DateTime.ToString("MMMM yyyy, dd", CultureInfo.InvariantCulture);
我认为您的代码是:
a.txndate.ToString("MMMM yyyy, dd", CultureInfo.InvariantCulture);
这将返回您想要的格式的字符串
This will return an string with the format you want
如果要更改语言,只需更改IFormatProvider(CultureInfo.InvariantCulture)
if you want to change de language you just need to change the IFormatProvider (CultureInfo.InvariantCulture)
这篇关于使用lambda表达式将datetime转换为MM yyyy,dd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文