日期循环取得有关问题

日期循环取得问题
求帮忙写一个循环日期取得问题啊。。
有一个时间段。
  String ls_a ,ls_b
  String ls_fo ,ls_to 
  
  ls_a='20110101'
  ls_b='20110531'
 怎么用循环 每次返回取得结果
  第一次取得的值:ls_fo ='20110101' ls_to='20110131'
  第三次取得的值:ls_fo ='20110201' ls_to='20110231'
  第四次取得的值:ls_fo ='20110301' ls_to='20110331'
.......

一直到。。小于 ls_b的日期。。循环退出。。中间有一个月不是31天的月
求高手帮忙写一下啊··
  谢谢了啊。。。。

等 急啊··谢谢了。。
  帮忙写一个语句。。。。
  
   


------解决方案--------------------
C/C++ code
String ls_a ,ls_b
String ls_fo ,ls_to  
   
ls_a='20110101'
ls_b='20110531'

date ld
int li_m
string ls_t
do while true
    if ls_a >= ls_b then exit //循环结束
    li_m = integer(mid(ls_a, 5, 2)) + 1
    if li_m = 13 then
        ld = date(string(integer(left(ls_a, 4)) + 1) + '-01-01')
    else
        ld = date(string(integer(left(ls_a, 4))) + '-' + string(li_m, '00') + '-01')
    end if
    //以下为你想要的结果
    ls_fo = ls_a //开始日期
    ls_to = string(relativedate(ld, -1), 'yyyymmdd') //结束日期

    //重新生成ls_a
    ls_a = string(ld, 'yyyymmdd')    
loop