UFN_DATE_COMPARETODATERANGE
Determines whether a date falls prior to a date range (-1), within the range (0), or to the future of the range (1)
Return
Return Type |
---|
int |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@DATEBEINGCOMPARED | date | IN | |
@DATEFROM | date | IN | |
@DATETO | date | IN |
Definition
Copy
create function dbo.UFN_DATE_COMPARETODATERANGE
(
@DATEBEINGCOMPARED date,
@DATEFROM date,
@DATETO date
)
returns int
with execute as caller
as begin
if @DATEBEINGCOMPARED is null
return 0;
if @DATEFROM is null and @DATETO is null
return 0;
if @DATEFROM is null
begin
if @DATEBEINGCOMPARED <= @DATETO
return 0;
else
return 1;
end
if @DATETO is null
begin
if @DATEBEINGCOMPARED >= @DATEFROM
return 0;
else
return -1;
end
if @DATEBEINGCOMPARED < @DATEFROM
return -1;
if @DATEBEINGCOMPARED > @DATETO
return 1;
return 0;
end