3

I'm trying to field calculate using a python script the number of business days between two given dates. Right now the dates are hard coded, but once I get the script working I will pass dates from two other fields to it. The script works fine in IDLE, giving me the correct number of business days, but when I put it in the field calculator it errors out:

ERROR 999999: Error executing function

The field is not nullable.

The field is set as "Short" with Precision at 5.

Pre-Logic Script Code:

import datetime as dt
import numpy as np

def workdays():
    start = dt.date(2018, 1, 31)
    end = dt.date(2018, 2, 12)
    days = np.busday_count(start, end)
    return days

Field=

workdays()
2

Your function is returning data type numpy.int64 which is probably not compatible with field type Short. Try return int(days)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.