UFN_STEWARDSHIPPLANMANAGERHISTORY_VALIDENDDATE

Validates that the end date of the specified historical stewardship plan manager is before the current manager's date range.

Return

Return Type
bit

Parameters

Parameter Parameter Type Mode Description
@STEWARDSHIPPLANID uniqueidentifier IN
@ENDDATE date IN

Definition

Copy


            create function dbo.UFN_STEWARDSHIPPLANMANAGERHISTORY_VALIDENDDATE
            (
                @STEWARDSHIPPLANID uniqueidentifier,
                @ENDDATE date
            )
            returns bit
            with execute as caller
            as begin

                if exists (
                    select 1
                    from
                        dbo.STEWARDSHIPPLAN
                    where
                        ID = @STEWARDSHIPPLANID and
                        (
                            (
                                (MANAGERSTARTDATE is not null) and
                                (MANAGERSTARTDATE < @ENDDATE)
                            ) or
                            (
                                (MANAGERENDDATE is not null) and
                                (MANAGERENDDATE < @ENDDATE)
                            )
                        )
                    )
                    return 0;

                return 1;

            end