how to calculate number of days in year in sql server 2008 -


i want calculate number of days in year in sql server 2008 management studio.

for example:

  • 2016 : 366
  • 2014 : 365

you can try:

  declare @y int;   set @y = 2014;    select datediff(day,  cast(@y char(4)),  cast(@y+1 char(4))) days 

result:

days 365 

2version comment:

 declare @y int;  set @y = 2014;   select datediff(day,  cast(cast(@y char(4)) date),  cast(cast(@y+1 char(4)) date)) dayscnt 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -