Quant Interview


Go Back   Quantitative Finance Forums - quantitative methods, technical analysis, automated trading systems > Software Development > SQL and Databases
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 11-10-2009, 11:31 PM   #1
bestdev
 
bestdev's Avatar
 
Join Date: May 2007
Posts: 2,299
Function that returns number of days in a year

Function that returns number of days in a year

Quote:
CREATE FUNCTION dbo.GetDaysInYear(@Date datetime)

RETURNS int
AS
BEGIN

RETURN CASE WHEN (YEAR(@Date) % 4 = 0 AND
YEAR(@Date) % 100 != 0) OR
(YEAR(@Date) % 400 = 0)
THEN 366
ELSE 365
END
END

GO
__________________

Impossible is temporary

bestdev is offline   Reply With Quote
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 07:40 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.