UFN_VALIDMONTHDAY
Return
Return Type |
---|
bit |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@monthday | char(4) | IN |
Definition
Copy
CREATE function dbo.UFN_VALIDMONTHDAY(@monthday char(4))
returns bit with execute as caller
as
begin
if @monthday is null
return 1
--4 chars are required
if len(@monthday) <> 4
return 0
if isnumeric(@monthday) = 0
return 0
declare @Month tinyint
set @Month = cast(left(@monthday, 2) as tinyint)
if (@Month < 1)
return 0
if @Month > 12
return 0
declare @Day tinyint
set @Day = cast(right(@monthday, 2) as tinyint)
if @Day < 1
return 0
if @Day > dbo.UFN_DAYSINMONTH(@Month, 2012) -- Specifying a leap year
return 0
return 1
end