UFN_SCHEDULE_DATEVALID
Returns the whether a date fits a start and end date time pair.
Return
Return Type |
---|
bit |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@dt | datetime | IN | |
@START | UDT_MONTHDAY | IN | |
@END | UDT_MONTHDAY | IN |
Definition
Copy
create function dbo.UFN_SCHEDULE_DATEVALID(@dt datetime, @START dbo.UDT_MONTHDAY, @END dbo.UDT_MONTHDAY) returns bit with execute as caller
as
begin
declare @retval as bit;
declare @MONTH as int;
declare @DAY as int;
if @dt is null
return 0;
set @MONTH = month(@dt);
set @DAY = day(@dt);
if @START <= @END
begin
if (@MONTH > left(@START,2)
or (@MONTH = left(@START,2) and @DAY>= right(@START,2)))
and
(@MONTH < left(@END,2)
or (@MONTH = left(@END,2) and @DAY<= right(@END,2)))
return 1;
end
else
begin
if (@MONTH > left(@START,2)
or (@MONTH = left(@START,2) and @DAY>= right(@START,2)))
or (@MONTH < left(@END,2)
or (@MONTH = left(@END,2) and @DAY<= right(@END,2)))
return 1;
end
return 0;
end