UFN_CONSTITUENT_ISFORMERPROSPECT
This functions returns whether a constituent had a prospect constituency in the past.
Return
Return Type |
---|
bit |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@CONSTITUENTID | uniqueidentifier | IN |
Definition
Copy
create function dbo.UFN_CONSTITUENT_ISFORMERPROSPECT(@CONSTITUENTID uniqueidentifier)
returns bit
with execute as caller
as begin
declare @CURRENTDATE datetime;
set @CURRENTDATE = getdate();
declare @UPPERBOUND datetime;
set @UPPERBOUND = dbo.UFN_DATE_GETLATESTTIME(@CURRENTDATE);
declare @LOWERBOUND datetime;
set @LOWERBOUND = dbo.UFN_DATE_GETEARLIESTTIME(@CURRENTDATE);
if exists(
select
ID
from
dbo.PROSPECTDATERANGE
where
PROSPECTDATERANGE.CONSTITUENTID = @CONSTITUENTID and
(PROSPECTDATERANGE.DATETO < @LOWERBOUND)
) return 1;
return 0;
end