Leap year fn? - Aaron Bertrand [SQL Server MVP] |
29-Aug-07 04:59:11
|
No, nothing built in. Simple enough to write yourself, though:
CREATE FUNCTION dbo.fnIsLeapYear
(
@Year SMALLINT
)
RETURNS BIT
AS
BEGIN
RETURN (SELECT ISDATE(RTRIM(@YEAR) + '0229'));
END
GO
SELECT dbo.fnIsLeapYear(1900);
SELECT dbo.fnIsLeapYear(2000);
SELECT dbo.fnIsLeapYear(2001);
SELECT dbo.fnIsLeapYear(2004);
SELECT dbo.fnIsLeapYear(2005); |
 |
| |
Leap year fn? - TheSQLGuru |
29-Aug-07 05:58:35
|
Thats a new one to add to my bag of tricks - assuming it really works!! :-)
--
TheSQLGuru
President
Indicium Resources, Inc. |
 |
| |
Leap year fn? - Aaron Bertrand [SQL Server MVP] |
29-Aug-07 06:06:02
|
In Katmai there are allegedly some gregorian dates that are misinterpreted
as either leap year when they weren't or not leap year when they were, but
for SQL 2005 at least for now this should suffice. :-) |
 |
| |
Leap year fn? - Uri Dimant |
30-Aug-07 03:14:49
|
David
declare @d datetime
set @d='20040210'
select 32-day(@d-day(@d)+32)
Just my two cents |
 |
| |