• The User Function is nothing more than a date function. It can be commented out and the program will run fine. You could subsititute select cast(getdate() as date) as 'User Date'

    USE [XX]

    GO

    /****** Object: UserDefinedFunction [dbo].[uf_AR_EndPrd_Date] Script Date: 10/14/2014 7:27:36 AM ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    --IF OBJECT_ID (N'dbo.ISOweek', N'FN') IS NOT NULL

    -- DROP FUNCTION dbo.ISOweek;

    --GO

    ALTER FUNCTION [dbo].[uf_AR_EndPrd_Date] ()

    RETURNS date

    AS

    BEGIN

    declare @cyr as int

    declare @cprd as int

    declare @pyr as int

    declare @pmth as int

    declare @Begdate as date

    declare @EndDate as date

    set @pmth = (select month(getdate())-1)

    set @pyr = (Select year(getdate())-1)

    if @pmth = 0

    begin

    set @pmth = 12

    end

    if @pmth >=1 and @pmth <12

    begin

    set @pyr = (select year(getdate()))

    end

    set @EndDate = (select Perdendt

    from servername.DB.dbo.SY40100

    where periodID = @pmth

    and year1 = @pyr

    and series = 3

    and odesctn = 'Receivables Cash Receipts')

    return(@Enddate)

    END