• Maybe if the function is only there to cope with null dates being stored as an origin point like 1st January 1900 or 1st January 1753, then he could replace stuff like this:

    WHERE dbo.AGM_isdatenull(RD.ReceiptDate)= 0

    with stuff like this:

    WHERE (RD.ReceiptDate IS NOT NULL AND RD.ReceiptDate NOT IN ('17530101','19000101'))

    or alternatively fix the existing data and whatever loads new data, so that nulls really get stored as nulls, and then just use WHERE RD.ReceiptDate IS NOT NULL