private void GetDataTimeInterval(DateTime begin_time, DateTime end_time, ref List<string> list)
      {
           list.Add(begin_time.ToShortDateString());
           if (begin_time.ToShortDateString() != end_time.ToShortDateString())
           {
            begin_time = begin_time.AddDays(1);
            GetDataTimeInterval(begin_time, end_time, ref list);//返回时间区间列表GetDataTimeInterval

}
}

调用:

List<string> list = new List<string>();
GetDataTimeInterval(Convert.ToDateTime(begin_date), Convert.ToDateTime(end_date), ref list);

此时返回的list就是两个日期中间的

比如GetDataTimeInterval(2019-07-01,2019-0704), ref list);

返回的list包含:2019-07-01,2019-07-02,2019-07-03,2019-07-4

相关文章:

  • 2022-12-23
  • 2022-01-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
相关资源
相似解决方案