我有一个关于日期函数的问题,是这样的:
id_day_1 = Today()
id_day_2 = Date(RelativeDate(Today(), -6))
em_start.Text = String(id_day_1,"yyyy年mm月dd日")
em_finish.Text = String(id_day_2,"yyyy年mm月dd日")
iidt_begin=iidt_begin = DateTime(Date(Mid(em_start.text,1,4)+"-"+Mid(em_start.text,7,2)+"-"+Mid(em_start.text,11,2)),Time(gi_starthour,0,0))
iidt_end = DateTime(Date(Mid(em_finish.text,1,4)+"-"+Mid(em_finish.text,7,2)+"-"+Mid(em_finish.text,11,2)),Time(gi_starthour,0,0))
我现在要增加一个日期的讯函数,在每增加一天时 循环一次
循环变量为 dtemp
即: dtemp 从 iidt_begin(2010-05-26 00:00:000)开始循环 到iidt_end(2010-06-02 00:00:000 )结束 每次增加一天(即2010-05-26 00:00:000 、2010-05-27 00:00:000、2010-05-28 00:00:000 …… 2010-06-02 00:00:000)
整数变量 li 每次加1
……………………………………
怎么才能做出这样的函数?
------解决方案--------------------
datetime d
d=id_day_2
do while d<id_day_1
li++
d=RelativeDate(d,1)
loop
------解决方案--------------------
long ll_days,ll_i
ll_days = DaysAfter(iidt_begin,iidt_end)
for ll_i = 1 to ll_days
dtemp = RelativeDate(iidt_begin,1)
messageBox("",string(dtemp,'YYYY-MM-DD'))
next