我需要预测的日期时间differnce细胞的阵列中......获取日期时间差在阵列
例如:
开始日期:二零一一年四月三十零日 要日期:05/30/2011
阵列单元包含从2011年4月30日的日期05/30/2011
我需要预测的日期时间differnce细胞的阵列中......获取日期时间差在阵列
例如:
开始日期:二零一一年四月三十零日 要日期:05/30/2011
阵列单元包含从2011年4月30日的日期05/30/2011
我认为你正在寻找这样的:
DateTime start = Convert.ToDateTime("04/30/2011");
DateTime end = Convert.ToDateTime("05/30/2011");
List<DateTime> dateArray = new List<DateTime>();
while (end > start.AddDays(1))
{
end= end.AddDays(-1);
dateArray.Add(end);
}
DateTime[] array = dateArray.ToArray();
谢谢Ashwani! – 2011-05-30 12:35:45
可以使用CalendarPeriodCollector this库:
// ----------------------------------------------------------------------
public void CalendarPeriodCollectorSample()
{
CalendarPeriodCollector collector =
new CalendarPeriodCollector(new CalendarPeriodCollectorFilter(),
new TimeRange(new DateTime(2011, 4, 30), new DateTime(2011, 5, 30)));
collector.CollectDays();
foreach (ITimePeriod period in collector.Periods)
{
Console.WriteLine("Period: " + period); // all days between 04/30/2011 and 05/30/2011
}
} // CalendarPeriodCollectorSample
您还可以指定斥天(节假日除外),或小时收集周期。
“预测”是什么意思?这个预测如何工作? – 2011-05-30 07:35:38
如果我们使用时间跨度,我们可以按日期,按天数,按小时...获取差异,但它返回的是整型值...但我需要在数组[]中的中间日期。 – 2011-05-30 07:59:51