如何在日期时间列表中获取日期? [英] How Can I Get Date Only In List Of Datetime ?
问题描述
列表与LT;日期时间> ListDT =新列表< datetime>();
ListDT包含
[0] = {10 / 6/2014 12:03:00 AM}
[1] = {10/6/2014 12:06:00 AM}
[2] = {10 / 7/2014 12:03:00 AM}
[3] = {10/7/2014 12:06:00 AM}
[4] = {10 / 8/2014 12:03:00 AM}
我只想过滤这里的所有日期,例如这里的
列表< datetime> ListFilter = new List< datetime>();
[0] = {10/6/2014}
[1] = { 2014年10月7日}
[2] = {10/8/2014}
List<datetime> ListDT = new List<datetime>();
ListDT contains
[0] = {10/6/2014 12:03:00 AM}
[1] = {10/6/2014 12:06:00 AM}
[2] = {10/7/2014 12:03:00 AM}
[3] = {10/7/2014 12:06:00 AM}
[4] = {10/8/2014 12:03:00 AM}
I just want to filter all the Date in my list like this here for example
List<datetime> ListFilter = new List<datetime>();
[0] = {10/6/2014}
[1] = {10/7/2014}
[2] = {10/8/2014}
推荐答案
请参阅:http://msdn.microsoft.com/en-us/library/system .datetime.date%28v = vs.110%29.aspx [ ^ ]。
-SA
您好,
试试这个
Hello ,
Try this
var list=ListDT.GroupBy(x => x.datecolumn.Date).Distinct().ToList();
谢谢
thanks
string str =10/6/2014;
string [] getDateArray = str.Split('/ ');
//在getDateArray中你可以获得Date作为数组索引的位置date
string date = getDateArray [0];
string str = "10/6/2014";
string[] getDateArray = str.Split('/');
// in getDateArray you Can Get Date as position of in array index of date
string date = getDateArray[0];
这篇关于如何在日期时间列表中获取日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!