UFN_ADDRESSPROCESS_SEASONALADDRESSES
Returns seasonal addresses based on the supplied date.
Return
Return Type |
---|
table |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@DATE | datetime | IN |
Definition
Copy
CREATE function dbo.UFN_ADDRESSPROCESS_SEASONALADDRESSES
(@DATE datetime)
returns table
as
return
(
select A.CONSTITUENTID,
A.ID as ADDRESSID
from dbo.ADDRESS A
inner join dbo.CONSTITUENT C on A.CONSTITUENTID = C.ID
where C.ISORGANIZATION = 0 and
A.DONOTMAIL = 0 and
A.STARTDATE <> '0000' and
((cast((right('0' + cast(month(@DATE) as varchar(2)), 2) + right('0' + cast(day(@DATE) as varchar(2)), 2)) as int) - cast(A.STARTDATE as int)) + 1231) % 1231 between 0 and ((cast(A.ENDDATE as int) - cast(A.STARTDATE as int)) + 1231) % 1231
and A.SEQUENCE = (select min(B.SEQUENCE) from dbo.ADDRESS B
where B.CONSTITUENTID = C.ID and
B.DONOTMAIL = 0 and
B.STARTDATE <> '0000' and
((cast((right('0' + cast(month(@DATE) as varchar(2)), 2) + right('0' + cast(day(@DATE) as varchar(2)), 2)) as int) - cast(B.STARTDATE as int)) + 1231) % 1231 between 0 and ((cast(B.ENDDATE as int) - cast(B.STARTDATE as int)) + 1231) % 1231)
)