C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






Count Number Of Days in a Year


Posted Date: 24 Apr 2008    Resource Type: Code Snippets    Category: SQL

Posted By: @@@ Hyderabadi Biryani @@@       Member Level: Diamond
Rating:     Points: 3



The sample code is a custom function that returns an integer stating the number of days in a given year. The input is given as a date.



CREATE FUNCTION [dbo].[ufn_CountNoOfDaysInYear] ( @pDate DATETIME )
RETURNS INT
AS
BEGIN

DECLARE @IsLeapYear BIT

SET @IsLeapYear = 0
IF (YEAR( @pDate ) % 4 = 0 AND YEAR( @pDate ) % 100 != 0) OR
YEAR( @pDate ) % 400 = 0
SET @IsLeapYear = 1

RETURN 365 + @IsLeapYear

END
GO





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
T-sql functions  .  Sql functions  .  Number of days in a year  .  Days in a year  .  Calculate leap year  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Calculate AGE
Previous Resource: How to get month name from a date in SQL Server
Return to Discussion Resource Index
Post New Resource
Category: SQL


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

teleconferencing service

Contact Us    Privacy Policy    Terms Of Use