Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sushma patle
Starting Member
15 Posts |
Posted - 2008-05-21 : 03:32:26
|
| what is the error in that function, please help to find outcreate function [dbo].[ufn_IsLeapYear] ( @pDate DATETIME) returns bitas begindeclare @b bit if (YEAR(@pDate)%4=0 ) AND YEAR(@pDate)%100 != 0)) set @b = 1 else if (YEAR(@pDate) % 400 = 0) set @b= 0Return(@b)endspatle |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-21 : 03:42:54
|
Year 2000 IS leap year even if it is divisable by 100.CREATE FUNCTION dbo.ufn_IsLeapYear( @pDate DATETIME)RETURNS BITASBEGIN DECLARE @b BIT SET @b = CASE WHEN YEAR(@pDate) % 400 = 0 THEN 1 WHEN YEAR(@pDate) % 100 = 0 THEN 0 WHEN YEAR(@pDate) % 4 = 0 THEN 1 ELSE 0 END RETURN @bEND E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|
|
|