• Two more options. Option 2 allows you to use the function in a CROSS APPLY in a query instead of using the Scalar UDF in the select part of a query. You will find that the cross apply is faster.

    DROP FUNCTION dbo.fFinYear;

    GO

    CREATE FUNCTION [dbo].[fFinYear] (@v_date datetime)

    RETURNS varchar(7) AS

    BEGIN

    return CAST(year(DATEADD(mm,9,@v_date)) - 1 as VARCHAR) + '/' + RIGHT(CAST(year(DATEADD(mm,9,@v_date)) as VARCHAR),2);

    END;

    GO

    select dbo.fFinYear('20110128');

    GO

    DROP FUNCTION dbo.fFinYear;

    GO

    CREATE FUNCTION [dbo].[fFinYear] (@v_date datetime)

    RETURNS table

    AS

    return select CAST(year(DATEADD(mm,9,@v_date)) - 1 as VARCHAR) + '/' + RIGHT(CAST(year(DATEADD(mm,9,@v_date)) as VARCHAR),2) as FiscalYear;

    go

    select * from dbo.fFinYear('20110128');

    go

    drop function dbo.fFinYear;

    GO