Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
sql_server 217
t-sql 211
tsql 116
sqlserver 96
BRH 78
#SQLServer 66
#TSQL 56
SQL Server 34
function 11
SSMS 9

Archive · View All
August 2007 17
August 2010 8
June 2012 7
June 2011 7
November 2007 7
August 2012 6
May 2012 6
November 2011 6
August 2011 6
October 2011 6

Madhivanan's TSQL Blog

Different ways to find out a Leap Year

Jan 5 2011 12:00AM by Madhivanan   

A Leap year contains an extra day so there are 366 days. There are many ways to find out whether the year is a Leap year. If the value of is_leap_year is 1 it is a Leap year otherwise it is not a Leap year.

Method 1 : General method

declare @year int
set @year=2000
		
select 
	case 
		when @year%400=0  then 1 
		when @year%100=0  then 0
		when @year%4=0  then 1
		else 0
	end as is_leap_year

Method 2 : Find if the day difference between Jan 01 of this year to Jan 01 of next year is 366

declare @year int
set @year=2000
		
select 
	case 
		when datediff(day,DATEADD(year,@year-1900,0),DATEADD(year,@year-1900+1,0))=366 then 1
		else 0
	end	as is_leap_year

Method 3 : Find if the day difference between Feb 01 to Mar 01 of this year is 29

select 
	case 
		when datediff(day,dateadd(month,1,DATEADD(year,@year-1900,0)),dateadd(month,2,DATEADD(year,@year-1900,0)))=29 then 1 
		else 0
	end	as is_leap_year

Method 4 : Find if the 60th day of this year falls in February last day (Feb 29)

declare @year int
set @year=2000
		
select 
	case 
		when day(dateadd(day,59,DATEADD(year,@year-1900,0)))=29 then 1 
		else 0
	end	as is_leap_year

Method 5 : Find the day of year for the last day of the year and subtract 365 to give 0 for non-leap year and 1 for leap year (Suggested by MVJ at this post)

declare @year int
set @year=2000

select
	IsLeapYear = datepart(dy,dateadd(yy,a.[Year]-1899,-1))-365
from
(		
select 
	[year]=@year 
) as a

Tags: t-sql, sql_server, sqlserver, tsql, BRH, #TSQL, #SQLServer, Leap year,


Madhivanan
3 · 40% · 12909
3
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

"Different ways to find out a Leap Year" rated 5 out of 5 by 3 readers
Different ways to find out a Leap Year , 5.0 out of 5 based on 3 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]