Author Topic: daytime[]  (Read 486 times)


  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
« on: January 09, 2015, 06:01:40 AM »
following the examples given in online doc
I ve written a small function which calculates the number of business days between today and a maturity date:

@xl_func ("datetime Maturity, datetime[] Holidays : int")
def BD (maturity,holidays):
    """returns number of business days betwen now and maturity,
    Holidays = list of holiday dates"""
    for i in holidays:
       if i.weekday() in (5,6) or (i-t).days<0 or(maturity-i).days<0:
    return  d-2*d/7 -h 

This seems to work fine when called in python ang returns the expected result
when called in XL it s always returning 0
the problem seems to come from the for loop
can it be that daytime[] as defined in Pyxll is not iterable?
I ve tried some test functions and when I use any iteration or indexing on a datetime[] variable I get the errors


  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: daytime[]
« Reply #1 on: January 09, 2015, 06:39:26 AM »
I understand the problem now
a daytime[] even if it spreads on one row is a list of lists: [[date1],[date2],[date3...]
so when you loop you have to index twice
for i in daytime:
  Di=i[0] # and not Di=i
« Last Edit: January 09, 2015, 08:56:38 AM by jelkhoury »