To get the list of years between two dates, Below sample code
is do the trick:
static void getYearsByDates(Args _args)
{
date fromDate;
date toDate;
int fromyear;
int toyear;
List yearList;
ListIterator iterator;
yearList = new
List(Types::String);
fromDate = mkDate(7,1,2009);
toDate = mkDate(10,2,2015);
fromyear = year(fromDate);
toyear = year (toDate);
while
(fromyear <= toyear)
{
yearList.addEnd(int2str(fromyear));
++fromyear;
}
iterator =
new ListIterator(yearList);
while(iterator.more())
{
info(strFmt("year = %1", iterator.value()));
iterator.next();
}

No comments:
Post a Comment