以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  日期段生成一个数据  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=59427)

--  作者:heying325
--  发布时间:2014/11/4 9:57:00
--  日期段生成一个数据
我有一个日期段,比如:2014-11-01 到 2014-11-04  。我想通过这个时间段生产一个数组 {”2014-11-01“,”2014-11-02“,”2014-11-03“,”2014-11-04“}          求助代码!
--  作者:Bin
--  发布时间:2014/11/4 10:05:00
--  
Dim d1 As Date = "2014-11-01"
Dim d2 As Date = "2014-11-04"
For i As Integer = d1.Day To d2.Day
  output.show(Format(d1,"yyyy-MM-") & format(i,"00"))
Next

--  作者:heying325
--  发布时间:2014/11/5 11:02:00
--  
老师!按照你的方法,要是同一个月份的时间段是没问题的,可是不同月份的时间段就不行了,这个该怎么弄呢?
--  作者:有点甜
--  发布时间:2014/11/5 11:05:00
--  
Dim d1 As Date = "2014-11-01"
Dim d2 As Date = "2014-12-04"
Do While d1 < d2
    output.show(d1)
    d1 = d1.AddDays(1)
Loop